@Override public BytesValues getBytesValues(boolean needsHashes) { // if you want hashes to be cached, you should rather store them on disk alongside the values // rather than loading them into memory // here - not supported for now, and probably not useful since this field data only applies to // _id and _uid? final BinaryDocValues values; final Bits docsWithField; try { final BinaryDocValues v = reader.getBinaryDocValues(field); if (v == null) { // segment has no value values = DocValues.EMPTY_BINARY; docsWithField = new Bits.MatchNoBits(reader.maxDoc()); } else { values = v; final Bits b = reader.getDocsWithField(field); docsWithField = b == null ? new Bits.MatchAllBits(reader.maxDoc()) : b; } } catch (IOException e) { throw new ElasticsearchIllegalStateException("Cannot load doc values", e); } return new BytesValues(false) { @Override public int setDocument(int docId) { this.docId = docId; return docsWithField.get(docId) ? 1 : 0; } @Override public BytesRef nextValue() { values.get(docId, scratch); return scratch; } }; }