How to query elements in an array

Json below (only _source part is shown) is for example purpose only is shows an document from a fictional real estate broker

Question: how do i query this document if it has lots with ownerId: "Jim Anderson"

{
.
.
.
  "_source": {
    "city": {
      "district10": [
       { "landlot1": {
          "price": 50,
          "size": 5,
          "ownerId": "Jim Anderson"
        }
      },
        {
          "landlot2": {
            "price": 45,
            "size": 9,
            "ownerId": "Anna Simson"
          }
        }
      ]
    }
  }
}

I tried something like this but didnt work

{
 
  "query": {
    "match": {
      "city.district10.landlot1.ownerId" : "Jim Anderson"
    }
  }
}

How to make this work?

You'll need to use nested docs in order to be able to distinguish array elements from each other.

thanks

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