user1809913
user1809913

Reputation: 1865

Is it possible to retrieve an object in an array that matches my query using elasticsearch?

Given a document like this:

{
  "id": "12345",
  "elements": [
    {
    "type": "configure",
    "time": 3000
    }
  ]
}

Is it possible to query for documents with an object in the elements array that have a type of configure and then also retrieve that specific object in the array so that I can also get the time value associated with that element (In this case 3000)?

Upvotes: 0

Views: 33

Answers (1)

Russ Cam
Russ Cam

Reputation: 125488

You can use nested inner_hits to retrieve details of the nested objects that match for a nested query. Note that elements will need to be mapped as a nested datatype field.

Upvotes: 1

Related Questions