简体   繁体   English

elasticsearch中的术语查询

[英]Terms query in elasticsearch

What is the difference between terms and term set query?术语和术语集查询有什么区别? How I can OR the query in term parameter?我如何在 term 参数中对查询进行 OR 查询?

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.您可以使用 bool 查询执行 OR。

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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