开发者

Disabling scoring in Lucene(.NET)

开发者 https://www.devze.com 2022-12-26 15:27 出处:网络
When searching, is there a way to disable scoring for any query? The scenario is that the user refines his query by trying different combinations of words, phrases etc., and needs realtime (well, rea

When searching, is there a way to disable scoring for any query?

The scenario is that the user refines his query by trying different combinations of words, phrases etc., and needs realtime (well, reasonably fast at least) responses on the number of hits.

Search time slows down a lot when there are millions of hits due to scoring, but the user really doesn't care about all these documents. As soon as he sees there are 1M+ hits he will start adding additional words to the query. A "Sort by relevance" option would allow him to do this quickly, while turning scoring back on when the number of hits is reasonable.

Is this possible?

I'm using Lucene.NET 2.9.2 开发者_StackOverflowbut AFAIK it is identical to the Java version.


Try ConstantScoreQuery. This only returns the hits, without scoring them.


In Lucene 2.9 you can use a custom Collector that can do what you want (get hits without scoring).

http://hudson.zones.apache.org/hudson/job/Lucene-trunk/javadoc/all/org/apache/lucene/search/Collector.html

0

精彩评论

暂无评论...
验证码 换一张
取 消