lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrzej Bialecki>
Subject Re: Set IDF value manually on a search query
Date Mon, 22 Mar 2010 18:35:58 GMT
On 2010-03-22 18:06, zsl wrote:
> I was thinking about that, but i dont know if it is the best option. Ty.

There is a certain trick to do this with the current API (let's hope the 
new API is more .. flexible .. ? ;) )

Implement a dummy Searcher that delegates most of its work to the real 
Searcher, except for docFreq(Term), where you return your arbitrary 
values. Then do Searcher.rewrite(Query) to expand the query, and then 
Query.weight(Searcher) to obtain a Weight - which uses your modified IDF.

Finally, use this Weight to run a query against your real Searcher.

You can see this approach implemented here:

though this contains some Solr-specific scaffolding, too.

Best regards,
Andrzej Bialecki     <><
  ___. ___ ___ ___ _ _   __________________________________
[__ || __|__/|__||\/|  Information Retrieval, Semantic Web
___|||__||  \|  ||  |  Embedded Unix, System Integration  Contact: info at sigram dot com

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message