发布以下查询时,我收到了错误响应
{"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"]}}]}}}}}
如何使此查询对我的自动完成搜索有效?
答案 0 :(得分:2)
prefix命令接受“值”而不是“前缀”。另外,“ boost”值是数字类型,因此不应将其用引号引起来。
应该是:
{"prefix":{"title":{"value":"of","boost":1.0}}}
代替:
{"prefix":{"title":{"prefix":"of","boost":"1.0"}}}