About elasticsearch returned innerhits for a query

I have a query which has 2 nested fields.After applying this query for an index documents the 2 fields are matched for a document and ES returned that document along with innerhits. But the innerhits contains only one field.But i want all the matched field objects.

my query looks like this
{
"query": {
"bool": {
"must": [
{
"constant_score": {
"filter": {
"nested": {
"inner_hits": {
"_source": true
},
"path": "penDocuments",
"query": {
"bool": {
"must": [
{
"match": {
"penDocuments.type": "Passport"
}
},
{
"match": {
"penDocuments.values": "zzzzz"
}
}
]
}
}
}
},
"boost": 100
}
},
{
"constant_score": {
"filter": {
"nested": {
"inner_hits": {
"_source": true
},
"path": "penDocuments",
"query": {
"bool": {
"must": [
{
"match": {
"penDocuments.type": "PAN"
}
},
{
"match": {
"penDocuments.values": "735fHgBT1"
}
}
]
}
}
}
},
"boost": 100
}
}
]
}
}
}

and my response innerhits is

"inner_hits": {
"penDocuments": {
"hits": {
"total": 1,
"max_score": 1.3862944,
"hits": [
{
"_index": "neglistindividual_junit",
"_type": "details",
"_id": "869",
"_nested": {
"field": "penDocuments",
"offset": 0
},
"_score": 1.3862944,
"_source": {
"type": "PAN",
"values": [
"735fHgBT1",
"Zwgt3ES21"
]
}
}
]
}
}
}

but i expected both pan and passport fields in the innerhits. How can i obtain that?

we can set individual names for inner hits
for example:
for first query
inner_hits:{
"name" : hit1
}
and for second query
inner_hits:{
"name": hit2
}

like this you can get all the innerhits without overwriting.

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