Sorting on distance from parent in has_parent query

Hi all,

I've been searching quite a lot but, so far without results, so I'm turning to you for some pointers.

I have 2 types of docs in my index. Rooms and Premises. Rooms have a premises as parent. The Premises (parents) have a location.

Now I want to create a query that shows the rooms matching certain critiria. One of the criteria is the distance from a certain location point.

So far so good, that works (has_parent query)

Now I want the results to be sorted based on that distance. But as the distance is in the parent, this doesn't seem to be very straight forward. I've been trying to mesh suggestions for sorting based on a parent field with suggestions for sorting on distance. But I didn't get anything to go for.

Are there any good pages out there that I didn't find? Could you jot down the idea that I should implement? I'm fairly new in ES.

Thx for any hints

Kind regards

Pieter

ES doesn't support sorting by a field inside a parent or child field. There is a workaround for sorting by parent or child field but it has limitations: https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-dsl-has-child-query.html#_sorting

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