elasticsearch bool query combine must with OR

后端 未结 6 765
小蘑菇
小蘑菇 2020-11-28 00:51

I am currently trying to migrate a solr-based application to elasticsearch.

I have this lucene query

(( 
    name:(+foo +bar) 
    OR info:(+foo +bar         


        
6条回答
  •  死守一世寂寞
    2020-11-28 01:04

    If you were using Solr's default or Lucene query parser, you can pretty much always put it into a query string query:

    POST test/_search
    {
      "query": {
        "query_string": {
          "query": "(( name:(+foo +bar) OR info:(+foo +bar)  )) AND state:(1) AND (has_image:(0) OR has_image:(1)^100)"
        }
      }
    }
    

    That said, you may want to use a boolean query, like the one you already posted, or even a combination of the two.

提交回复
热议问题