首页 > 解决方案 > Elasticsearch“match_phrase_prefix”无法正常工作

问题描述

我有一个自定义分析器:

"s5_analyzer": { 
  "filter": "lowercase",
  "type": "custom",
  "tokenizer": "whitespace"
}

和映射:

"PRODUCT": {
  "type": "text",
  "fields": {
    "keyw": {
      "type": "text",
      "analyzer": "s5_analyzer"
    }
  }
}

有了记录"PRODUCT": "the brown fox jumped2:, over 1200 the lazy dog",我正在使用这个查询:

{
  "query": {
    "match_phrase_prefix": {
      "PRODUCT.keyw": {
        "query": "the brown fox"
      }
    }
  }
}

这些查询正常工作,结果即将到来

"query": "the brow"
"query": "the brown"
"query": "the brown fox"

但是通过这些查询我没有结果:

"query": "the brown f"
"query": "the brown fo"
"query": "the bro"

我的索引只有一条记录,所以max_expansions不是问题。为什么match_phrase_prefix不能正常工作?

Elasticsearch 版本是 7.10.2

谢谢。

标签: elasticsearch

解决方案


推荐阅读