elasticsearch在query多个字段的问题

查询:

{'query': {'match_phrase_prefix': {'id': '1799612', 'site_id': '3', 'sort_type': '1'}}}

结果:

{'error': {'root_cause': [{'type': 'parsing_exception', 'reason': "[match_phrase_prefix] query doesn't support multiple fields, found [id] and [site_id]", 'line': 1, 'col': 59}], 'type': 'parsing_exception', 'reason': "[match_phrase_prefix] query doesn't support multiple fields, found [id] and [site_id]", 'line': 1, 'col': 59}, 'status': 400

小弟es新手,请问这个问题应该如何解决

阅读 3.5k
1 个回答

现在手头没有,没法测,试试:

{
    "query": {
        "bool": {
            "must": [
                {'match_phrase_prefix': {'id': '1799612'}},
                {'match_phrase_prefix': {'site_id': '3'}}
            ]
        }
    }
}

文档链接:https://www.elastic.co/guide/...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进