问题
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