Reputation: 10704
I am trying to add search filter to products depending on price.
Lucene.Net.Search.Filter filter = NumericRangeFilter.NewFloatRange("AnalyzedPrice", minPrice, maxPrice, true, true);
But its Not returning any results. When I pass this filter as null output given is correct.
I am indexing my products' price using
doc.Add(new Field("AnalyzedPrice", pv.Price.ToString(), Field.Store.YES, Field.Index.ANALYZED));
Any Solutions?
Upvotes: 0
Views: 250
Reputation: 10704
Following line solved my issue
doc.Add(new NumericField("AnalyzedPrice", Field.Store.YES, true).SetFloatValue((float)pv.Price));
Upvotes: 0
Reputation: 51430
You have to use the NumericField
class for range queries to work (or FloatField
for instance if you're using a more recent Lucene version through IKVM).
This class will encode your field data - it will not be stored textually anymore.
Upvotes: 1