Search Lucene LongField with Query

How can I use TermQuery to exactly match LongField?

+4
source share
2 answers

Consider a warning in the NumericUtils API

NOTE. This API is for internal purposes only and may be changed in incompatible ways in the next version.

I noticed that this is becoming a problem for some people, as the NumericUtils API has really changed significantly from version 3.6 to Version 4.0 . I would recommend not using it directly.

NumericRangeQuery . , .

, , . NumericFields . , , . , , , .

+6
BytesRef ref = new BytesRef();    
NumericUtils.longToPrefixCoded( 12L, 0, ref );
Query q = new TermQuery( new Term( fieldname, ref ) );
+1

All Articles