使用`或`opeator在Elastic Search中执行多个“匹配短语”查询

时间:2018-01-09 16:54:01

标签: ruby-on-rails elasticsearch match-phrase

{
  "query": {
    "bool": {
      "or": [
         {"match_phrase": {"text":  "first phrase"}},
         {"match_phrase": {"text":  "second phrase"}}
      ]
    }
 }
}

我想匹配所有包含完全按照输入的短语的文档。

1 个答案:

答案 0 :(得分:0)

{
    "query": {
        "constant_score" : {
            "filter" : {
                 "bool" : {
                    "or" : [
                        { "term" : { "text" : "first phrase" } }, 
                        { "term" : { "text" : "second phrase" } } 
                    ]
                }
            }
        }
    }
}