MySQL:在全文搜索函数match()和against()中搜索Like'%%'查询等效项

时间:2018-06-07 07:07:44

标签: mysql

我一直在尝试使用像'%term%'查询longtext列,但这花费的时间太长了。 Mysql EXPLAIN显示没有使用索引。

全文搜索功能match()和against()未返回所需的结果。我已尝试过+ term,term *,“term”, term ,..但无法找到正确的查询方式,以便我得到与Like'%完全相同的结果术语%'。

全文搜索在更短的时间内给我结果但不是所希望的。如何在mysql中使用全文搜索来实现这一目标?或者有没有办法可以改善我的'%term%'搜索?

这是样本数据:

1   "ruleSetId"
2   [{"_ID":0,"Block":"ValidatorBlock","Key":"VALUE_VALIDATION_RULES","Description":"Validation Rule Failed.","DisplayName":"Value Validation Rule","Include":true,"Severity":"Alert","RowIndex":"0"}]
3   Value Validation Rule
4   "ExtractColumnName": "SP_RULE"
5   ", "BCC (L), LC", "ClosingRule", "Demo Portfolio
6   ", "BCC L, LC", "ClosingRule", "Demo Portfolio
7   ", "BCC L, LC", ClosingRule, "Demo Portfolio
8   ", "BCC L, LC", Closing Rule, "Demo Portfolio
9   [{"_ID":0,"Block":"ValidatorBlock","Key":"","Description":"Validation Rule Failed.","DisplayName":"Value Validation Rule","Include":true,"Severity":"Alert","RowIndex":"0"}]
10  [{"_ID":0,"Block":"ValidatorBlock","Key":"VALUE_VALIDATION_RULES","Description":"Validation Failed.","DisplayName":"Value Validation ","Include":true,"Severity":"Alert","RowIndex":"0"}]
11  "ruleSetId _"
12  "_ ruleSetId "
13  ruleSetId
14   : ruleSetId 
15  "ExtractColumnName": "SP$RULE"
16  "ExtractColumnName": "SPRULE"
17  "ExtractColumnName": "SPRULE"

Query1:从testfulltext中选择*,其中config为'%rule%';给我所有17行,这是期望的结果。

Query2:select * from testfulltext where match(config)against('+ rule *'IN BOOLEAN MODE);给了我10行。

0 个答案:

没有答案