Hello,
I'm sure the issue is not depending on the fact you're having three parameters.
it's working for me using the following code, and making sure the
field you are referring to is stored in the index:
Code:
@Field(index= Index.UN_TOKENIZED,store=Store.YES)
Code:
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
OpenBitSet bitSet = new OpenBitSet( reader.maxDoc() );
TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms();
while ( termEnum.next() ) {
String fieldName = termEnum.term().field();
if ( fieldName.equals( field ) ) {
termDocs.seek( termEnum.term() );
if ( termDocs.next() ) {
int doc = termDocs.doc();
Document document = reader.document( doc );
String fieldValue = document.get( field );
if ( fieldValue != null ) {
int actualInteger = (Integer.valueOf( fieldValue )).intValue();
if ( actualInteger >= min && actualInteger <= max ) {
bitSet.set( doc );
System.out.println( "INTEGER IS :: " + actualInteger );
}
}
}
}
}
return bitSet;
}
I'm not sure this is the best performing solution, especially as you're reading from the document - the same issue for which you need Store.
Depending on the range between
min and
max it might be better to wrap a RangeQuery into the filter, or to use seek() in a loop on exact terms, scanning the whole range of possibilities and setting the bits at each seek.
If you don't store the field, you're getting null from document.get( field ), that's why I added the nullcheck (as the index might contain other entities of a different type, and not have this field stored)