Sort using nested_filter internal implementation and performance concerns


(Erich Lin-2) #1

The description for nested_filter is:

"Common case is to repeat the query / filter inside the nested filter or
query. "

If my search involves something like:

GET /library/book/_search
{
"query": {
"nested": {
"path": "prices",
"score_mode": "total",

  •  "query": {*
    
  •    "match": {*
    
  •      "region": "cities"*
      }
    }
    
    }
    },
    "sort": [
    {
    "price": {
    "mode": "avg",
    "order": "asc",
    "nested_path": "prices",
    "nested_filter": {
  •      "query": {*
    
  •        "match": {*
    
  •          "region": "cities"*
          }
        }
      }
    }
    
    },
    "_score"
    ]
    }

If you run a sort on a nested field and use the nested_filter, how is that
implemented internally?

Secondly, are there any performance concerns or gotchas?

In this case, the query is repeated for the hits and for the sort. How much
of a concern is this? What if there were multiple sort fields used and each
sort field has query repeated?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5888ee5d-1648-4f6c-8e60-62c5539a8b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2