Mustafa Kunwa
Mustafa Kunwa

Reputation: 867

Lucene Range Search for .NET

I have Min and Max Value indexed. it should return when the value is between min and max when the search function is called. I'm new to Lucene .NET 4.8.0

any help will be appreciated

Upvotes: 0

Views: 263

Answers (1)

Mysterion
Mysterion

Reputation: 9320

You need to use Lucene.Net.Search.NumericRangeQuery, this query matches numeric values within specific range.

In your case (in Lucene syntax) it would be:

max:[value TO *] AND min:[* TO value]

Where value is your input. If you want to the values to be exclusive - you should use { instead of [

In Lucene.NET it should be something like this:

Query q = NumericRangeQuery.newFloatRange(“fieldName”, new Float(value), float.MaxValue, true, true);

And similar for second part, with replacing * to a minimum float value

Upvotes: 2

Related Questions