Scoring docs with ordinal rank sort or normalization across field values


(Rodrigo Nunes) #1

Ok, bear with me on what I am trying to accomplish. Suppose I have a doc with the following fields, representing a user entity:
{
name: string,
location: geo_point,
like_count: integer,
views: integer,
reputation: float
}

Now, I want to run a query on name, filter by range in the location field (only users less than 100mi away, for example) and until there all is good. Pretty straight forward. Now, over the result set I want to sort them with the following criteria: use the sum of ORDINAL POSITION of each of the result documents (yeah, throwing away the initial query scoring completely) in this subset INDIVIDUALLY in each of the categories: like_count, views and reputation. I can't find a way to do this...not even sure it is possible. So the final 'score' of a doc would be the sum of that ordinal position, for example (1st in views, 3rd in like_count and 20th in reputation would have a score of 24 ( 1 + 3 + 20). The lowest score would be the first listed doc. I thought about rescoring, post_filters, aggregations, function scripts...but seems like I can't find a way to normalize the values and just use a numeric output as I don't know a priori the ranges (min...max) of each field. I would think that Lucene keeps that kind of stat, but I might be wrong. Anybody can help me find a solution to implement this sort, in case I am missing something super simple ? Thx in advance...


(system) #2