简体   繁体   中英

Lucene JSON query syntax

I'm trying to query an Elasticsearch-wrapped Lucene index with edge ngrams in it, and cannot make sense of the documentation to figure out how to apply boolean operators to it. I have this:

{
  "query":{
  "bool":{
    "should":[
      {
        "match":{
          "name.partial":"+henry +james"
        }
      }
    ]
  }
}}

That doesn't work (I get results with henry and without james, and vice versa), and neither do \\"henry james\\", or henry AND james - I get the same things back no matter what. How do I get the behavior I want?

You should use the query_string query for that. If you use the match query, I think the only thing that you can do is specify the query and the operator to use like this:

{
    "match" : {
        "message" : {
            "query" : "this is a test",
            "operator" : "and"
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM