Note that using many facet.query= parameters may be expensive.
Another way to solve this is to pre-compute the ranges as plain strings in 
another field during indexing.
This can be done in your app prior to indexing or by creating a new FieldType 
for your range. Here's a field type that computes the strings for you. Simply 
do a copyField from your "price" field to e.g. "price_s", and facet on 
"price_s" instead of "price":

<fieldtype name="priceclass" class="solr.TextField">
  <analyzer>
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.PatternReplaceFilterFactory" 
pattern="^([0-9]{0,2})([\.,][0-9]{1,2})?$" replacement="0 - 99" replace="all" />
    <filter class="solr.PatternReplaceFilterFactory" 
pattern="^(1[0-9][0-9]|2[0-4][0-9]|)([\.,][0-9]{1,2})?$" replacement="100 - 
249" replace="all" />
    <filter class="solr.PatternReplaceFilterFactory" 
pattern="^(2[5-9][0-9]|[3-4][0-9][0-9])([\.,][0-9]{1,2})?$" replacement="250 - 
499" replace="all" />
    <filter class="solr.PatternReplaceFilterFactory" 
pattern="^([5-9][0-9][0-9])([\.,][0-9]{1,2})?$" replacement="500 - 999" 
replace="all" />
    <filter class="solr.PatternReplaceFilterFactory" 
pattern="^([0-9]{4,5})([\.,][0-9]{1,2})?$" replacement="999 -" replace="all" />
  </analyzer>
</fieldtype>

It adds to your index size, but is optimized for query speed.

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

On 5. nov. 2010, at 16.03, jayant wrote:

> 
> Thank you both. Faceting is now working on a range.
> -- 
> View this message in context: 
> http://lucene.472066.n3.nabble.com/How-to-Facet-on-a-price-range-tp1846392p1848716.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to