Module org.elasticsearch.server
Package org.elasticsearch.index.mapper
Interface SourceLoader.SyntheticFieldLoader
- All Known Implementing Classes:
FlattenedSortedSetDocValuesSyntheticFieldLoader
,SortedNumericDocValuesSyntheticFieldLoader
,SortedSetDocValuesSyntheticFieldLoader
,StringStoredFieldFieldLoader
- Enclosing interface:
- SourceLoader
public static interface SourceLoader.SyntheticFieldLoader
Load a field for
SourceLoader.Synthetic
.
SourceLoader.SyntheticFieldLoader
s load values through objects vended
by their storedFieldLoaders()
and docValuesLoader(org.apache.lucene.index.LeafReader, int[])
methods. Then you call write(org.elasticsearch.xcontent.XContentBuilder)
to write the values to an
XContentBuilder
which also clears them.
This two loaders and one writer setup is specifically designed to
efficiently load the _source
of indices that have thousands
of fields declared in the mapping but that only have values for
dozens of them. It handles this in a few ways:
docValuesLoader(org.apache.lucene.index.LeafReader, int[])
must be called once per document per field to load the doc values, but detects up front if there are no doc values for that field. It's linear with the number of fields, whether or not they have values, but skips entirely missing fields.storedFieldLoaders()
are only called when the document contains a stored field with the appropriate name. So it's fine to have thousands of these declared in the mapping and you don't really pay much to load them. Just the cost to buildMap
used to address them.- Object fields that don't have any values loaded by either means bail out of the loading process and don't pass control down to any of their children. Thus it's fine to declare huge object structures in the mapping and you only spend time iterating the ones you need. Or that have doc values.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Loads doc values for a field.static interface
Sync for stored field values. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondocValuesLoader
(org.apache.lucene.index.LeafReader leafReader, int[] docIdsInLeaf) Build something to load doc values for this field or returnnull
if there are no doc values for this field to load.boolean
hasValue()
Has this field loaded any values for this document?AStream
mapping stored field paths to a place to put them so they can be included in the next document.void
Write values for this document.
-
Field Details
-
NOTHING
Load no values.
-
-
Method Details
-
storedFieldLoaders
Stream<Map.Entry<String,SourceLoader.SyntheticFieldLoader.StoredFieldLoader>> storedFieldLoaders()AStream
mapping stored field paths to a place to put them so they can be included in the next document. -
docValuesLoader
SourceLoader.SyntheticFieldLoader.DocValuesLoader docValuesLoader(org.apache.lucene.index.LeafReader leafReader, int[] docIdsInLeaf) throws IOException Build something to load doc values for this field or returnnull
if there are no doc values for this field to load.- Parameters:
docIdsInLeaf
- can be null.- Throws:
IOException
-
hasValue
boolean hasValue()Has this field loaded any values for this document? -
write
Write values for this document.- Throws:
IOException
-