简体   繁体   中英

Terms query in elasticsearch

What is the difference between terms and term set query? How I can OR the query in term parameter?

For example:

GET /_serarch
{
    "Query":{
        "term":{"user":"kimchy"},{"Age": 25}
    }
}

Terms Set Query you can provide an array of terms to match any of them in the document.

GET /my-index/_search
{
   "query": {
      "terms_set": {
          "codes" : {
              "terms" : ["abc", "def", "ghi"],
              "minimum_should_match_field": "required_matches"
          }
      }
   }
}

The term query finds documents that contain the exact term specified.

POST _search
{
  "query": {
  "term" : { "user" : "Kimchy" } 
  }
}

You can do OR using the bool query.

"query": {
  "bool" : {     
    "should" : [
      { "term" : { "tag" : "wow" } },
      { "term" : { "tag" : "elasticsearch" } }
    ],
    "minimum_should_match" : 1,
  }
}

}

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