【问题标题】:Elastic Search: query_string query does not match exact phrase in full text search弹性搜索:query_string 查询与全文搜索中的精确短语不匹配
【发布时间】:2019-03-12 20:28:10
【问题描述】:

我正在使用Elastic search 6.2.3。我们使用query_string full-text-query 进行full-text 搜索。目前,如果我们搜索lazy brown fox,它会搜索包含所有这些词lazybrownfox 的任何文件,但它不会搜索exact-phrase 'lazy brown fox',即使默认slopzero

这是一个例子:

{
  "query": {
    "query_string": {
      "fields": [],
      "query": "lazy AND brown AND fox"
    }
  }
}  

我查看了match-phrase-query,但问题是我们必须在match-phrase-query 中指定field name(s),而在string-query 中,它在字段选项中使用空白数组。

请建议,如何使用query_stringfull text-query获得精确的词组匹配结果?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    不要查看匹配短语查询以在多个字段上运行短语查询,而是查看支持短语类型查询的 multi_match

    POST phrase_index/_search
    {
      "query": {
        "multi_match": {
          "query": "this is where it should work",
          "fields": [],
          "type": "phrase"
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 2023-03-28
      • 2017-01-09
      • 2019-02-11
      相关资源
      最近更新 更多