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

hello ,

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

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

 "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 .

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

how could I do that ?

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. 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 page. It contains also lot of useful information on how to ask for help.

I found the answer here -

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