I use NumericField
write a Integer
in lucene Index:
doc.add(
new NumericField("id",Integer.MAX_VALUE,Field.Store.YES,true)
.setIntValue(123)
);
Now I have a problem,How Can I write a search expression by id filed(NumericField)?
I tried:
id:123
and id:intToPrefixCoded(123)
but nothing for return
Reference:
This doesn't work because numeric fields' internal representation differs from their textual representation. You should either construct numeric queries manually or extend Lucene query parser. All you need to do is to extend the new*Query
(Term, Range, ...) methods and have an if/else test on the field name to know whether you should create a numeric query or a regular query.
See Lucene wiki for more information.