Reputation: 51
I am using the apache lucene to perform fulltext search in my application. Now I have to perform a range query to search records between two integers.
I have created my index using following code
private void set(String fieldName, String fieldValue, Document luceneDocument, LuceneOptions options, Float boost) {
if (fieldName != null && fieldValue != null) {
Field luceneField =
new Field(fieldName,
fieldValue.toLowerCase(),
options.getStore(),
options.getIndex(),
options.getTermVector());
luceneField.setBoost(boost);
luceneDocument.add(luceneField);
}
}
The above method creates the lucene indexes for my field name "magnitude" which possible values are positive and negative integers in between the range of -999 to 9999.
Now if I create a lucene range query like (magnitude:[10 to 345]) or (magnitude:[10 to null]). I am not getting the correct number of records.
Upvotes: 0
Views: 1123
Reputation: 7305
You need to define an IntField
to let Lucene interpret the values as numeric.
Upvotes: 0