Module org.elasticsearch.server
Package org.elasticsearch.index.mapper
Interface SourceLoader.SyntheticFieldLoader
- All Known Subinterfaces:
- CompositeSyntheticFieldLoader.DocValuesLayer,- CompositeSyntheticFieldLoader.Layer
- All Known Implementing Classes:
- BinaryDocValuesSyntheticFieldLoader,- CompositeSyntheticFieldLoader,- CompositeSyntheticFieldLoader.MalformedValuesLayer,- CompositeSyntheticFieldLoader.StoredFieldLayer,- SortedNumericDocValuesSyntheticFieldLoader,- SortedSetDocValuesSyntheticFieldLoaderLayer,- SourceLoader.DocValuesBasedSyntheticFieldLoader,- StringStoredFieldFieldLoader
- Enclosing interface:
- SourceLoader
public static interface SourceLoader.SyntheticFieldLoader
Load a field for 
SourceLoader.Synthetic.
 
 SourceLoader.SyntheticFieldLoaders 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 build- Mapused 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 SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceLoads doc values for a field.static interfaceSync for stored field values.
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptiondocValuesLoader(org.apache.lucene.index.LeafReader leafReader, int[] docIdsInLeaf) Build something to load doc values for this field or returnnullif there are no doc values for this field to load.Returns the canonical field name for this loader.booleanhasValue()Has this field loaded any values for this document?default voidprepare()Perform any preprocessing needed before producing synthetic source and deduce whether this mapper (and its children, if any) have values to write.voidreset()Resets the loader to remove any stored data and prepare it for processing new document.default booleansetIgnoredValues(Map<String, List<IgnoredSourceFieldMapper.NameValue>> objectsWithIgnoredFields) Allows for identifying and tracking additional field values to include in the field source.AStreammapping stored field paths to a place to put them so they can be included in the next document.voidWrite values for this document.
- 
Field Details- 
NOTHINGLoad no values.
 
- 
- 
Method Details- 
storedFieldLoadersStream<Map.Entry<String,SourceLoader.SyntheticFieldLoader.StoredFieldLoader>> storedFieldLoaders()AStreammapping stored field paths to a place to put them so they can be included in the next document.
- 
docValuesLoaderSourceLoader.SyntheticFieldLoader.DocValuesLoader docValuesLoader(org.apache.lucene.index.LeafReader leafReader, int[] docIdsInLeaf) throws IOException Build something to load doc values for this field or returnnullif there are no doc values for this field to load.- Parameters:
- docIdsInLeaf- can be null.
- Throws:
- IOException
 
- 
preparedefault void prepare()Perform any preprocessing needed before producing synthetic source and deduce whether this mapper (and its children, if any) have values to write. The expectation is for this method to be called beforehasValue()andwrite(XContentBuilder)are used.
- 
hasValueboolean hasValue()Has this field loaded any values for this document?
- 
writeWrite values for this document.- Throws:
- IOException
 
- 
setIgnoredValuesdefault boolean setIgnoredValues(Map<String, List<IgnoredSourceFieldMapper.NameValue>> objectsWithIgnoredFields) Allows for identifying and tracking additional field values to include in the field source.- Parameters:
- objectsWithIgnoredFields- maps object names to lists of fields they contain with special source handling
- Returns:
- true if any matching fields are identified
 
- 
fieldNameString fieldName()Returns the canonical field name for this loader.
- 
resetvoid reset()Resets the loader to remove any stored data and prepare it for processing new document. This is an alternative code path towrite(org.elasticsearch.xcontent.XContentBuilder)that is executed when values are loaded but not written. Loaders are expected to also reset their state after writing currently present data.
 
-