I am using nested query in Elasticsearch search query. Something like this:
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"match": {
"id": {
"query": "department1"
}
}
},
{
"match": {
"id": {
"query": "company1"
}
}
}
]
}
}
]
}
},
{
"bool": {
"should": [
{
"bool": {
"should": [
{
"nested" : {
"path" : "peoples",
"ignore_unmapped" : "true",
"query" : {
"bool" : {
"must" : [
{
"match" : {
"peoples.firstName" : "firstName12"
}
}
]
}
},
"inner_hits": { }
}
},
{
"nested" : {
"path" : "entities",
"ignore_unmapped" : "true",
"query" : {
"bool" : {
"must" : [
{
"match" : {
"entities.firstName" : "firstName13"
}
}
]
}
},
"inner_hits": { }
}
}
]
}
}
]
}
}
]
}
}
And then I want to access to inner_hits data from sorting script:
"sort": [
{
"_script": {
"type": "string",
"order": "asc",
"script": {
"lang": "painless",
"inline": "**inner_hits**"
}
}
}
]
Is it possible?