views:

153

answers:

2

Hi,

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 but AFAIK it is identical to the Java version.

A: 

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

bajafresh4life
Thanks for info. I tried creating a NullCollector (does nothing) and it does indeed work. Unfortunately the search time is the same as with the default collector. The time is not spent in the collector, it is spent in the TermScorer, which still calls my NullCollector for every document in the result set.
That doesn't surprise me. In order to find the # of docs for a query, Lucene has to do the work of looking up the docs that matched the terms. If real-time performance is really important for you, maybe look into splitting your indexes and searching them in parallel
bajafresh4life
+1  A: 

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

Yuval F