Get int
Fieldcache.ints Ints = FieldCache.DEFAULT.getInts (Atomicreader reader, String field, Boolean Setdocswithfield);
Get the DocId field value
int value = Ints.get (docId);
Get string
Bytesref bytesref = new Bytesref ();
Binarydocvalues terms = FieldCache.DEFAULT.getTerms (Atomicreader reader, String field, Boolean Setdocswithfield);
Terms.get (doc,bytesref);
String value = bytesref.utf8tostring ();
Lucene 4.10.0
Binarydocvalues terms = getterms (Atomicreader reader, String field, Boolean Setdocswithfield);
String value = Terms.get (docId). utf8tostring ();
Filter based on Fieldcache
Filter f = Fieldcacherangefilter.newintrange ("left", 0, True, true);
Filter filter = new Fieldcachetermsfilter ("type", New Bytesref[]{new Bytesref ("Science"), New Bytesref ("It")});
Note of place: 1. The field values in Fieldcache are read from the inverted table, not from the field values stored in the index file, so the sorted fields must be set as indexed fields
2. The fields used for sorting cannot be split at index (tokenized) because each document corresponds to only one field value in the Fieldcache array, and the cache will only be saved in the dictionary after the value.
3. Fieldcache is the most memory-intensive part of Lucene, and most memory overflow errors are caused by it, requiring special attention.