Sorting document based on parent attributes


(Erik Miller) #1

I'm having trouble returning documents in the expected order. It relates to television listings. The child document is the timeslot (a tv station and time) and the parent is the program that would be on the station at that time.

I'm using es 2.3 and scripting is turned off on the cluster, so that is not an option.

The query so far is just querying for all timeslots and attempting to sort on the programId.

My query is below...

{
  "filter": {
  "has_parent": {
  "parent_type": "program",
  "score_mode": "min",
  "query": {
    "function_score": {
      "functions": [
        {
          "field_value_factor": {
            "factor": 1
            "field": "programId"
          }
        }
      ],
      "query": {}
    }
  },
  "inner_hits":{"_source":["programId"]}
}
 },
 "sort": "_score",
  "size":20,
  "_source":["programId"]
}

(system) #2

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