[英]Connect dynamic array of search terms to string in PHP / MySQL
Using Laravel 5.3 and MySQL 5.7.17. 使用Laravel 5.3和MySQL 5.7.17。 I store text in a TEXT column (don't know the limit).
我将文本存储在TEXT列中(不知道限制)。
**I want to search this text for different variations of different words in different languages that should lead to the same match. **我想在此文本中搜索不同语言的不同单词的不同变体,从而导致相同的匹配。
Example:** 例:**
'bird' -> bird
'Vogel' -> bird
'pájaro' -> bird
Try #1: Set up a table with two columns: 尝试#1:建立包含两列的表:
Advantage: only need one table Disadvantage: serialize and unserialize data all the time - bad performance? 优点:只需要一个表缺点:一直在对数据进行序列化和反序列化-性能不好?
Try#2: Set up two tables, one containing the real, right search terms I am gonna use for my code. 尝试#2:设置两个表,其中一个表包含我将用于代码的真正正确的搜索词。 The second containing all alternative search terms that are linked via a 'One to Many' relationship in Laravel.
第二个包含所有通过Laravel中“一对多”关系链接的替代搜索词。
Then search for all terms in the second table and, if found, give me a match for the corresponding real string in the first. 然后在第二个表中搜索所有术语,如果找到,请在第一个表中给我匹配相应的真实字符串。
Advantage: probably better performance Disadvantage: two different tables. 优点:性能可能更好缺点:两个不同的表。
Since I am dealing with words that don't always have a close connection to each other, I can't rely on stuff like spell checker. 由于我要处理的词并不总是彼此紧密联系的,所以我不能依靠拼写检查器之类的东西。
want to manage library of the alternative search terms manually anyway. 想要手动管理替代搜索词库。 Is there a better solution to do this?
有更好的解决方案吗?
How about 1 table: 一张桌子怎么样:
I guess that VARCHAR would support better indexing than TEXT. 我猜想VARCHAR比TEXT支持更好的索引。 Is there an upper limit that you could impose (50 characters? 100 characters?)?
是否有上限(50个字符?100个字符?)?
| c1 | c2 |
|----------+------------|
| bird | bird |
| vogel | bird |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.