Full Text Search always returns empty result set

守給你的承諾、 提交于 2021-02-08 08:27:49

问题


I have a table named 'fact' with title column, that should be full text index.

Firstly, I add a full text index:

ALTER TABLE fact ADD FULLTEXT title_fts (title)

So, I insert row:

INSERT INTO fact (id, title) VALUES ('1', 'red blue yellow ok green grey ten first wise form');

And then I perform search:

select * from fact f where contains (f.title, '"red" or "blue"')

When I perform the following query, or any other query with 'contains' statement, I get emtpy result set:

I have to use this statement, not against-match or like. Does anyone happen to have an idea why is this happening? Thank you.


回答1:


There are two really important concepts when using full text search. The first is the minimum work length (see here). By default, the value is 4, meaning that words shorter than this are ignored. Bye-bye "red", "ok", "ten" and other short words.

The second important concept is the stop words list (see here). This would also get rid of "ok" and "first".

Your text doesn't have "blue" and "red" is ignored, so your query doesn't return anything.

You will need to re-build your index after you decide on the words that you really need to include.



来源:https://stackoverflow.com/questions/31164398/full-text-search-always-returns-empty-result-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!