参考文章:Elasticsearch 搜索数组字段_hhhzua的专栏-CSDN博客_elasticsearch 查询数组

 1、搜索 数组字段 tags 中同时存在元素 str_astr_b

{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "tags": "str_a"
          }
        },
        {
          "term": {
            "tags": "str_b"
          }
        }
      ]
    }
  }
}

2、搜索 数组字段 tags 中存在元素 str_a 或 str_b

{
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "tags": [
              "str_a",
              "str_b"
            ]
          }
        }
      ]
    }
  }
}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐