Mike Mikeman
Mike Mikeman

Reputation: 11

Rangequery No Longer Works in Lucene 2.9.4.1

After upgrading from Lucene.Net 2.3.1.3 to 2.9.4.1, a RangeQuery no longer works. I tried NumericRangeQuery and TermRangeQuery with no luck. The RangeQuery searches for Long values in a range (ex - [4000 TO 5000] should find 4500).

Here is the code:

    private static Query BuildNumericRangeQuery(NumericRangeSearchParam.NumericRangeField range)
    {
        var startTerm = new Term(range.FieldName, NumberTools.LongToString(range.Start));
        var endTerm = new Term(range.FieldName, NumberTools.LongToString(range.End));
        return new RangeQuery(startTerm, endTerm, true);
    }

Anyone else run into the same issue? Any insight would be appreciated!

Upvotes: 0

Views: 121

Answers (1)

Mike Mikeman
Mike Mikeman

Reputation: 11

The issue was related to the Index Crawler padding the data to 10 characters with the following:

var transformation = (int) Math.Floor(rating*1000);
var result = ToLexographical(transformation, 10); //which results in 0000004500 as an example.

I changed it to ToLexographical(transformation, 4) which results in a 4 character string (ex - 4500). Not sure how this worked before because [4000 TO 5000] shouldn't technically find 0000004500 with Lexographic ordering.

Upvotes: 1

Related Questions