mysql coercibility_互斥式MySQL全文搜索(Mutually Exclusive MySQL Full-Text Search)

互斥式MySQL全文搜索(Mutually Exclusive MySQL Full-Text Search)

假设我有一个包含以下列的MySQL表:

|variables|

1. | 'a'     |

2. | 'a b'   |

3. | 'a b c' |

4. |   ...   |

如何构建不忽略列条目中的空格的MySQL全文搜索?

例如,我想以下查询只返回第1行:

SELECT column FROM table WHERE MATCH variables AGAINST ('a')

但是,实际上,此查询将返回1-3行,因为所有三行都包含字母“a”。

Suppose I had a MySQL table with the following column:

|variables|

1. | 'a'     |

2. | 'a b'   |

3. | 'a b c' |

4. |   ...   |

How can I construct a MySQL Full-Text search that doesn't ignore white space in the column entries?

For example, I would like the following query to return only row 1:

SELECT column FROM table WHERE MATCH variables AGAINST ('a')

As it is, however, this query would return rows 1–3 because all three rows contain the letter 'a'.

原文:https://stackoverflow.com/questions/8234342

更新时间:2019-10-11 23:13

最满意答案

您的搜索规则不清楚,但这可能是正则表达式搜索比全文查询更好地为您服务的情况。

Your search rules are unclear, but this may be a case where a regular expression search will serve you better than a full-text query.

2011-11-22

相关问答

基本思想是从文本中构建索引作为列表属性(词干和删除停用词)。 要提高性能,请将list属性移动到子实体中,以使用“关系索引”。 这可以防止将可能很大的列表作为默认提取组的一部分加载 - 您只需要查询。 您将不得不使用低级别api来执行只有密钥查询才能返回父类的密钥,然后可以使用它来获取匹配的项目。 Basic idea is to build an index as a list property from the text (stemmed and with stop words removed

...

答案是IN BOOLEAN MODE 。 如果你使用布尔模式,那么mysql将忽略该键存在于超过50%的行中。 同时它具有非常强大和有用的能力: AGAINST ('*key*') 。 The answer is IN BOOLEAN MODE . If you use boolean mode then the mysql will ignore that the key is present in more then 50% of the rows. In the same time it h

...

我不认为全文搜索支持此功能。 事实上,很难找到一种蛮力的方式来做到这一点。 这是一种强力方法: where trim(replace(replace(replace(title, $word1, ''), $word2), ''), $word3, '')) = ''

这并不完美,因为“松苹果”将匹配“松苹果”。 嗯。 。 。 还有另一种正则表达式: where title like concat('^(', replace('word1 word2 word3', ' ', '|'),

...

这可以。 我一般我建议熟悉ElasticSearch映射类型和选项。 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html This is fine. I general I would suggest getting familiar with ElasticSearch mapping types and options. http://www.elasticsearch.org/g

...

为列定义单个CHARACTER SETS ,将覆盖在表级别设置的默认排序规则。 每个列都有默认的latin1归类(即latin1_swedish_ci )。 您可以通过运行SHOW CREATE TABLE来查看它。 在FULLTEXT查询中,索引列的COERCIBILITY为0 ,即所有全文查询都转换为索引中使用的排序规则,反之亦然。 您需要从列中删除CHARACTER SET定义或将所有列显式设置为latin1_german_ci : CREATE TABLE `hotels` (

`Ho

...

MySQL中的全文搜索忽略了两种类型的单词:停止单词和短于某些阈值的单词。 您可以在此处阅读停用词列表。 在你的情况下特别感兴趣的是'second'这个词。 默认情况下,仅保留4个字符或更长字符的单词用于搜索目的。 因此, 'son'被忽略了。 所以,您的查询相当于: SELECT name, MATCH (name,aliases) AGAINST ('inFamous:') AS relevance

FROM games_search

ORDER BY relevance DESC;

我不确

...

您的搜索规则不清楚,但这可能是正则表达式搜索比全文查询更好地为您服务的情况。 Your search rules are unclear, but this may be a case where a regular expression search will serve you better than a full-text query.

考虑通过用[[:space:]]替换空白测试来简化。 (我不知道Javascript是否理解该符号。) Consider simplifying by replacing whitespace tests with [[:space:]]. (I don't know if Javascript understands that notation.)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值