弹性搜索错误-[前缀]查询不支持[前缀]

时间:2019-12-28 16:50:45

标签: elasticsearch elastic-stack

发布以下查询时,我收到了错误响应

{"error":{"root_cause":[{"type":"parsing_exception","reason":"[prefix] query does not support [prefix]","line":1,"col":119}],"type":"parsing_exception","reason":"[prefix] query does not support [prefix]","line":1,"col":119},"status":400}

这是我的POST查询:

{"from":0,"size":10,"sort":{"_score":"desc"},"query":{"bool":{"must":{"bool":{"should":[[{"prefix":{"title":{"prefix":"of","boost":"1.0"}}}],{"multi_match":{"query":"of","fields":["title^1.0"]}},{"query_string":{"query":"(\"of\")","fields":["title^1.0"]}}]}}}}}

如何使此查询对我的自动完成搜索有效?

1 个答案:

答案 0 :(得分:2)

prefix命令接受“值”而不是“前缀”。另外,“ boost”值是数字类型,因此不应将其用引号引起来。

应该是:

{"prefix":{"title":{"value":"of","boost":1.0}}}

代替:

{"prefix":{"title":{"prefix":"of","boost":"1.0"}}}