全文搜索始终返回空结果集 [英] Full Text Search always returns empty result set

查看:85
本文介绍了全文搜索始终返回空结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标题栏为'fact'的表,该表应为全文索引.

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)

所以,我插入一行:

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

然后我执行搜索:

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

当我执行以下查询或带有"contains"语句的任何其他查询时,我得到空结果集:

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.

推荐答案

使用全文本搜索时,有两个确实重要概念.第一个是最小工作长度(请参见此处).默认情况下,该值为4,表示短于此长度的单词将被忽略.再见红色",确定",十"等简短单词.

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.

这篇关于全文搜索始终返回空结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆