Is it even possible?

Let's take an example and then I will explain what am I trying to solve.

Suppose my mapping is as follows:

{
  "parent_id": { "type": "integer" },   
  "mydata": {
    "type": "nested",
    "dynamic": "strict",
    "properties": {
      "name": {"type": "string"},
      "location": { "type": "geo_point"} 
    }                     
  }

}

Here I want to find all documents (in pagination way = 10 docs per page) matching some criteria, but in that result set, I want to keep ONLY one best match the highest scored) document with unique parent_id. That means suppose in the result, there are five such documents which have same parent_id, then I will pick one of those based on the highest score among them. However, in the end, the pagination should ALWAYS return me the desired (say 10) numbers of the result after the elimination. Is it even possible to do at the query time? I am using ES 2.3

Try using inner hits with your nested query:
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-inner-hits.html

Ivan

How inner_hits gonna solve this problem?

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