mysql Word IndexedDB 的设计

egdjgwm8  于 2023-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(105)

我有一个约1000000页,索引,我需要找到一组关键字最接近的网页。
我目前的想法是为每一页创建一个字符串,其中包括重要的单词,沿着出现的次数。因此,每一行都是(页面ID、关键字)-唯一索引和出现次数
然后当我做一个查找,我应该能够搜索每个字,并创建一个分数。
我担心的是,该表可以很容易地数百万行,我不知道如何容易找到一个页面,涉及5个关键字产生的分数。
有没有人有任何建议来改进这个计划,使它更快,更少的密集使用。

at0kjp5o

at0kjp5o1#

mysql> SELECT title FROM fti WHERE MATCH(title) AGAINST('+windows +query +linux' IN BOOLEAN MODE);
+--------------------------------------------------------------------------+
| title                                                                    |
+--------------------------------------------------------------------------+
| Same Mysql Update query giving different result in linux and windows     |
| Re: Same Mysql Update query giving different result in linux and windows |
| Re: Same Mysql Update query giving different result in linux and windows |
| Re: Same Mysql Update query giving different result in linux and windows |
| Re: Same Mysql Update query giving different result in linux and windows |
| Re: Same Mysql Update query giving different result in linux and windows |
+--------------------------------------------------------------------------+
6 rows in set (0.01 sec)

mysql> SELECT COUNT(*) FROM fti WHERE MATCH(title) AGAINST('windows query linux' IN BOOLEAN MODE);
+----------+
| COUNT(*) |
+----------+
|    18758 |
+----------+
1 row in set (0.04 sec)

mysql> SELECT title FROM fti WHERE MATCH(title) AGAINST('windows query linux' IN BOOLEAN MODE) LIMIT 11;
+-------------------------------------------------------------------------+
| title                                                                   |
+-------------------------------------------------------------------------+
| Connecting from PHP on one linux box to another linux running MySQL     |
| Re: Connecting from PHP on one linux box to another linux running MySQL |
| export hebrew from linux to windows                                     |
| Performance on Linux vs Windows                                         |
| Backup Transfer from Windows Mysql to Linux Mysql                       |
| Re: Performance on Linux vs Windows                                     |
| Copy specific tables from windows to Linux                              |
| Re: Copy specific tables from windows to Linux                          |
| From Linux to Windows                                                   |
| Different results on Linux and windows                                  |
| Re: Different results on Linux and windows                              |
+-------------------------------------------------------------------------+
11 rows in set (0.02 sec)

mysql> SELECT title, MATCH(title) AGAINST('windows query linux') AS score FROM fti WHERE MATCH(title) AGAINST('+windows +query +linux') LIMIT 11;
+--------------------------------------------------------------------------+--------------------+
| title                                                                    | score              |
+--------------------------------------------------------------------------+--------------------+
| Connecting from PHP on one linux box to another linux running MySQL      | 13.917098999023438 |
| Re: Connecting from PHP on one linux box to another linux running MySQL  | 13.917098999023438 |
| Same Mysql Update query giving different result in linux and windows     | 12.674331665039062 |
| Re: Same Mysql Update query giving different result in linux and windows | 12.674331665039062 |
| Re: Same Mysql Update query giving different result in linux and windows | 12.674331665039062 |
| Re: Same Mysql Update query giving different result in linux and windows | 12.674331665039062 |
| Re: Same Mysql Update query giving different result in linux and windows | 12.674331665039062 |
| Re: Same Mysql Update query giving different result in linux and windows | 12.674331665039062 |
| export hebrew from linux to windows                                      | 11.582389831542969 |
| Performance on Linux vs Windows                                          | 11.582389831542969 |
| Re: Performance on Linux vs Windows                                      | 11.582389831542969 |
+--------------------------------------------------------------------------+--------------------+
11 rows in set (0.04 sec)

mysql> SELECT COUNT(*) FROM fti;
+----------+
| COUNT(*) |
+----------+
|   185079 |
+----------+
1 row in set (0.03 sec)

摘要

  • MySQL的FULLTEXT速度很快。
  • 我的表是你的表的18%,但即使找到10%的行也很快。
  • 有多种变体(BOOLEANNATURAL LANGUAGE、带/a不带+等)。
  • 您需要在SELECTWHERE中使用MATCH来查看数字并按“相关性”对其进行排序。
  • 索引声明只是FULLTEXT KEY title ( title ),; title可以是VARCHARTEXT

相关问题