lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucas Cotta <>
Subject How to implement a custom boost function
Date Mon, 03 Oct 2016 22:49:07 GMT

I'm new in Solr (4.7.2) and I was given the following requirement:

Given a query such as:

studentId:(875141 OR 873071 OR 875198 OR 108142 OR 918841 OR 870688 OR
107920 OR 870637 OR 870636 OR 870635 OR 918792 OR 107721 OR 875078 OR
875166 OR 875151 OR 918829 OR 918808)

I want the results to be ordered by the same order the elements were
informed in the query. This would be similar to MySQL's ORDER BY FIELD(id,

I have tried to use term boosting
in the query but that only works when I use big factors like this:
OR 875166^10000 OR 875151^1000 OR 918829^100OR 918808^10

But that would cause the query to be too big in case I have 200 ids for

So it seems I need to implement a custom FunctionQuery.
I'm a little lost on how to do that. Could someone please give me an idea?
Which classes should my custom class extend from? Where should I place this
class? Should I add to Solr project it self and regenerate the JAR?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message