简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM