There is a sorting problem that I'm struggling with.
Let's say there are players that compete on an arbitrary number of tracks,
and who have a ranking on those tracks.
I want to query the results by track_id and get a list of the players that
competed on it, sorted by ranking.
What I'm doing now is querying for "tracks.track_id": 42, and sorting with
"sort":"tracks.ranking".
The problem is that if a player competed on more than one track,
ElasticSearch would pick its best value for "tracks.ranking" and sort using
that value. Obviously this brings wrong results.
How can I make it sort on the "tracks.ranking" value that corresponds to the
given "tracks.track_id" ?
Is there a better mapping for this need, or can this be solved with a
custom_score script?
There isn't really a way to do it currently, even with custom_score
script. I have an idea on how to solve such "parent child" relationship, but
need some time to iron it out... .
-shay.banon
On Tue, Sep 28, 2010 at 11:49 AM, Michel Valdrighi michelv@gmail.comwrote:
Hello,
There is a sorting problem that I'm struggling with.
Let's say there are players that compete on an arbitrary number of tracks,
and who have a ranking on those tracks.
I want to query the results by track_id and get a list of the players that
competed on it, sorted by ranking.
What I'm doing now is querying for "tracks.track_id": 42, and sorting with
"sort":"tracks.ranking".
The problem is that if a player competed on more than one track,
Elasticsearch would pick its best value for "tracks.ranking" and sort using
that value. Obviously this brings wrong results.
How can I make it sort on the "tracks.ranking" value that corresponds to
the given "tracks.track_id" ?
Is there a better mapping for this need, or can this be solved with a
custom_score script?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.