Lucene4.7.2 Fieldcache Get Value

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.