Access to inner_hits from painless script during sorting


(Александр Чипиженко) #1

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?


How to retrieve a field value from inner_hits filtered object
(Ryan Ernst) #2

It is not possible, in any scripting language (not just painless). Inner hits are completely separate documents within lucene, but scripts operate on a single document at a time.


(system) #3

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