lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucas Cotta <lucco...@gmail.com>
Subject Re: How to implement a custom boost function
Date Tue, 04 Oct 2016 01:45:39 GMT
I actually could also use a custom similarity class that always returns 1.0
then I could use small boost factors such as ^1, ^2, ^3, etc.

But I want to do this only in some specific queries (that may contain other
fields besides studentId)

How could I do this, use the custom similarity class only for some queries?
Is it possible?

Thanks!

2016-10-03 19:49 GMT-03:00 Lucas Cotta <luccotta@gmail.com>:

> Hello,
>
> 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, 3,2,5,7,8,1).
>
> I have tried to use term boosting
> <https://wiki.apache.org/solr/SolrRelevancyCookbook#Boosting_Ranking_Terms>
> in the query but that only works when I use big factors like this: 875078^100000
> 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
> instance.
>
> 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?
>
> Thanks
>

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