views:

325

answers:

1

How is Lucene's ConstantScoreRangeQuery better than the old RangeQuery?

In what case should you use still use RangeQuery?

+1  A: 

According to the RangeQuery documentation in your link, A ConstantScoreRangeQuery:

  • is faster than RangeQuery.
  • does not cause a BooleanQuery.TooManyClauses exception if the range of values is large.
  • does not influence scoring based on the scarcity of individual terms that may match.

Suppose you are interested in scarcer terms being scored higher (say you are looking in a range of hours, but want the scarcer hours to be scored higher - maybe you are looking for a "slow" period of the day to run a backup process). In that case the older RangeQuery seems preferable.

The next generation will be the TrieRangeQuery, currently in the contrib section. It will probably part of the Lucene 2.9 core. It provides faster range queries than both other methods.

Yuval F