[英]Confusion on mysql full text search
I m having little confusion using MySQL fulltext. 我在使用MySQL全文时有点困惑。 I have database whose charset is set to utf-8
and collation set to utf8_unicode_ci
我的数据库的字符集设置为utf-8
,排序规则设置为utf8_unicode_ci
I have following flow of searching products. 我有以下搜索产品的流程。 User chooses from the flow below to search any product 用户从以下流程中选择以搜索任何产品
My confusion is. 我的困惑是。
varchar
and text
datatype field only. 由于全文仅在varchar
和text
数据类型字段中受支持。 How to get relevant results if many fields user selects for filter is in enum
如何获得相关的结果,如果许多领域用户选择的过滤器是在enum
enum
. 在这里按全文相关性排序是否起作用,因为存在许多enum
类型的字段。 Edit For better understand for example 编辑例如以更好地理解
This search is for those specially who knows what to buy but doesn't know anything else. 此搜索针对的是那些特别知道什么东西但不知道其他东西的人。 Like I need a Mobile PHone, but I don't know anything else, I just select its type(Wifi/without wifi) from combo, I then select camera (with/without), I then select other few features like this. 就像我需要移动电话一样,但是我什么都不知道,我只是从组合中选择其类型(Wifi /不带wifi),然后选择相机(带/不带),然后选择其他一些功能。 I then specify price range I can afford, I then want phone available in store in particular location. 然后,我指定我可以负担的价格范围,然后在特定位置的商店中购买手机。 For this I type location A, location B, location C
. 为此,我输入location A, location B, location C
I want results based on either of these location. 我想要基于这些位置的结果。 And I want to order results according to the nearest match of the search parameter specified. 我想根据指定的搜索参数的最接近顺序对结果进行排序。 Exact match to nearest match, then least nearest match. 精确匹配到最接近的匹配,然后是最不匹配的匹配。 Hope this helps 希望这可以帮助
Can anybody throw some light on this? 有人可以对此有所启发吗?
Thanks 谢谢
The documentation on the Full-Text Search Functions
page states that FULLTEXT
can only be used with MyISAM, however , MySQL 5.6 added support for the FULLTEXT
index with InnoDB (see Section 14.2.4.12.3
on the InnoDB Table and Index
page). Full-Text Search Functions
页面上的文档指出, FULLTEXT
只能与MyISAM一起使用, 但是 ,MySQL 5.6通过InnoDB添加了对FULLTEXT
索引的支持(请参见InnoDB Table and Index
页面上的Section 14.2.4.12.3
)。 If your table(s) are setup as MyISAM, then yes - you should have support; 如果您的表设置为MyISAM,则可以-您应该有支持; with InnoDB, potentially - pending on your MySQL version. 可能与InnoDB配合使用-取决于您的MySQL版本。
To enable the full-text search, you should add a FULLTEXT
index only on the fields that you're going to use the search on (no point to add it to fields you won't). 要启用全文本搜索,您应该仅在要使用搜索的字段上添加FULLTEXT
索引(不要将其添加到不需要的字段中)。 A FULLTEXT
index can only be applied to CHAR
, VARCHAR
, and TEXT
column-types, so that may be a start. FULLTEXT
索引只能应用于CHAR
, VARCHAR
和TEXT
列类型,因此可能只是一个开始。 Your product names may be too short to worry about a FULLTEXT
index (consider maybe a HASH index instead), but your product descriptions (if you have them) would be really good for it. 您的产品名称可能太短而不必担心FULLTEXT
索引(可以考虑使用HASH索引),但是您的产品描述(如果有)非常适合。
enum
data is good to index with a BTREE
index, not a FULLTEXT
one. enum
数据最好使用BTREE
索引而不是FULLTEXT
索引。
Not sure; 不确定; could you post an example of which fields would be queried and ordered and their data-types to give a better image as to what you need? 您能否发布一个示例,说明将查询和排序哪些字段及其数据类型,以更好地了解您的需求?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.