# Search where inside array ( like , search where in ) inside nested

**URL:** <https://discuss.elastic.co/t/search-where-inside-array-like-search-where-in-inside-nested/340307>\
**Category:** Elasticsearch\
**Created:** [August 8, 2023, 12:56am UTC](https://discuss.elastic.co/t/search-where-inside-array-like-search-where-in-inside-nested/340307 "2023-08-08T00:56:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Murilo\_Livorato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/murilo_livorato/32/123848_2.png) [@Murilo\_Livorato](https://discuss.elastic.co/u/Murilo_Livorato)\
**Post date:** [August 8, 2023, 12:56am UTC](https://discuss.elastic.co/t/search-where-inside-array-like-search-where-in-inside-nested/340307/1 "2023-08-08T00:56:55Z")

</div>

hello ,

I have a nested search .  
It is working like this -

```auto
GET /products/_search
{
   "size": 100, 
 "query": {
    "bool": {
     "must": [
		{
		    "nested": {
		      "path": "owner",
		      "query": {
		            "match": { "owner.id": 1 }
		        }
		      }
		    },
      ]
    }
  }
}

```

```auto
 "hits": [
      {
        "_index": "products",
        "_id": "Mlbyz4kBgvOTcbqQPyPj",
        "_score": 3,
        "_source": {
          "timestamp": "2023-05-31",
          "owner": {
            "id": 1,
            "name": "Bob"
          }
        }
      },
      {
        "_index": "metric-property-broker-daily-2023-05",
        "_id": "NFbyz4kBgvOTcbqQPyPsdfj",
        "_score": 3,
        "_source": {
          "timestamp": "2023-05-04",
          "owner": {
            "id": 2,
            "name": "John"
          }
        }
      },
        {
        "_index": "metric-property-broker-daily-2023-05",
        "_id": "NFbyz4kBgvOTcbqQPyPsdfj",
        "_score": 3,
        "_source": {
          "timestamp": "2023-05-04",
          "owner": {
            "id": 4,
            "name": "Ana"
          }
        }
      },

```

I wold like to seatch inside in array , something like this -  
to bring me all the results that has owner with ids 1 AND 3 .

```auto
GET /products/_search
{
   "size": 100, 
 "query": {
    "bool": {
     "must": [
    {
        "nested": {
          "path": "owner",
          "query": {
                "match": { "owner.id": [1,3] }
            }
          }
        },
      ]
    }
  }
}

```

how could I do that ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 8, 2023, 9:22am UTC](https://discuss.elastic.co/t/search-where-inside-array-like-search-where-in-inside-nested/340307/2 "2023-08-08T09:22:55Z")

</div>

I can't see why you are using nested here:

```
    {
      "timestamp": "2023-05-04",
      "owner": {
        "id": 4,
        "name": "Ana"
      }
    }

```

There's no array.

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can **copy and paste in Kibana dev console** , click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Have a look at the [Elastic Stack and Solutions Help · Forums and Slack | Elastic](https://elastic.co/community/help) page. It contains also lot of useful information on how to ask for help.

---

<div class="post-metadata">

**Author:** ![Murilo\_Livorato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/murilo_livorato/32/123848_2.png) [@Murilo\_Livorato](https://discuss.elastic.co/u/Murilo_Livorato)\
**Post date:** [August 8, 2023, 7:10pm UTC](https://discuss.elastic.co/t/search-where-inside-array-like-search-where-in-inside-nested/340307/3 "2023-08-08T19:10:59Z")

</div>

I found the answer here -

[![](https://us1.discourse-cdn.com/elastic/original/3X/d/4/d4ea8c5e831878dd636c960d34ee53d92737dbf3.jpeg "Elastic Search Queries : Searching in Nested Array of Documents and Filtering Q by Keval Jain") ](https://www.youtube.com/watch?v=HpNYqIPvy7c)

---

<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:** [September 5, 2023, 7:11pm UTC](https://discuss.elastic.co/t/search-where-inside-array-like-search-where-in-inside-nested/340307/4 "2023-09-05T19:11:26Z")

</div>

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