Query Execution order?

Hi,

I have query like this:

POST data-*/_search
{  "_source":  [ "Date","Source", "Name","company" ],
"query": {
    "nested": {
      "path": "List",
      "inner_hits": {
       "_source": [
          "university","Name","Code","State","Status","Articles","PIN"
        ]  
      },
"query": {
    "bool": { 
      "must": {
        "term": { "List.PIN":{"value":149}}
      },
      "filter": {
        "terms":{"List.Code":[276,915,319]} }
}
}
}
}
} 

I have data-* indices which contain 1000 documents . I want to know whether _source will work first or after bool query. Why because if _source worked first then it will take 1000 documents content and then remove as per bool query which will take time. Or it will run _source after bool query so that it have to take 3 doc's since List.Code has 3 id's

Thanks

The inner_hits part is executed after the search during the fetch phase so the _source is retrieved only for the top hits that match the query.

Thanks @jimczi

SO, you are saying _source will only apply on the hits of bool query. Right?

Correct me if i am wrong

Thanks

Sort of yes since inner_hits is applied to each top hits returned in the response. If your search matches 1M documents, it will be applied to the 10 best document returned by the query.

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