# How to query Array of Objects

**URL:** <https://discuss.elastic.co/t/how-to-query-array-of-objects/226980>\
**Category:** Elasticsearch\
**Created:** [April 7, 2020, 6:25pm UTC](https://discuss.elastic.co/t/how-to-query-array-of-objects/226980 "2020-04-07T18:25:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prathako](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@prathako](https://discuss.elastic.co/u/prathako)\
**Post date:** [April 7, 2020, 6:25pm UTC](https://discuss.elastic.co/t/how-to-query-array-of-objects/226980/1 "2020-04-07T18:25:13Z")

</div>

Mapping:

```auto
{
   "log":{
      "properties":{
         "detail":{
            "type":"nested",
            "properties":{
               "attribute":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "newValue":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               }
            }
         },
         "source":{
            "type":"text",
            "fields":{
               "keyword":{
                  "type":"keyword",
                  "ignore_above":256
               }
            }
         },
         "status":{
            "type":"text",
            "fields":{
               "keyword":{
                  "type":"keyword",
                  "ignore_above":256
               }
            }
         }
      }
   }

```

Data:

```auto
[
   {
      "_index":"audit_test_2",
      "_type":"log",
      "_id":"706yUXEBcaL3UicXEjIg",
      "_score":1.6486586,
      "_source":{
         "status":"Successful",
         "source":"Control Room",
         "detail":[
            {
               "attribute":"Name",
               "oldValue":null,
               "newValue":"Folder1"
            },
            {
               "attribute":"Version",
               "oldValue":null,
               "newValue":"2.0.0-20200114-060012"
            },
            {
               "attribute":"Status",
               "oldValue":null,
               "newValue":"DISABLED"
            }
         ]
      }
   },
   {
      "_index":"audit_test_2",
      "_type":"log",
      "_id":"8E6yUXEBcaL3UicXIzK0",
      "_score":1.6486586,
      "_source":{
         "status":"Successful",
         "source":"Control Room",
         "detail":[
            {
               "attribute":"Name",
               "oldValue":null,
               "newValue":"Folder2"
            },
            {
               "attribute":"Version",
               "oldValue":null,
               "newValue":"2.0.0-20200114-060012"
            },
            {
               "attribute":"Status",
               "oldValue":null,
               "newValue":"DISABLED"
            }
         ]
      }
   }
]

```

My current query:

```auto
{
  "query": {
    "nested": {
      "path": "detail",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "detail.newValue.keyword": "DISABLED"
              }
            }
          ]
        }
      }
    }
  }
}

```

How can I modify the query to get the result of one JSON object having "newValue": "Folder1" && "newValue": "DISABLED"? The above query expectedly returns both objects.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 5, 2020, 6:25pm UTC](https://discuss.elastic.co/t/how-to-query-array-of-objects/226980/2 "2020-05-05T18:25:16Z")

</div>

Closed on May 5, 2020, 6:25pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
