public interface Source
The source of a document. Note that, while objects returned from
source()
and internalSourceRef() are immutable, objects implementing this interface
may not be immutable themselves.-
Method Summary
Modifier and TypeMethodDescriptionstatic Sourceempty(XContentType xContentType) An empty Source, represented as an empty mapdefault ObjectextractValue(String path, Object nullValue) For the provided path, return its value in the source.filter(SourceFilter sourceFilter) Apply a filter to this source, returning a new Sourcestatic SourcefromBytes(BytesReference bytes) Build a Source from a bytes representation with an unknown XContentTypestatic SourcefromBytes(BytesReference bytes, XContentType type) Build a Source from a bytes representation with a known XContentTypestatic SourcefromMap(Map<String, Object> map, XContentType xContentType) Build a Source from a Map representation.A byte representation of the sourcestatic SourceBuild a source lazily if one of its methods is calledsource()A map representation of the sourceThe content type of the source, if stored as bytes
-
Method Details
-
sourceContentType
XContentType sourceContentType()The content type of the source, if stored as bytes -
source
A map representation of the sourceImportant: This can lose precision on numbers with a decimal point. It converts numbers like
"n": 1234.567to adoublewhich only has 52 bits of precision in the mantissa. This will come up most frequently when folks write nanosecond precision dates as a decimal number. -
internalSourceRef
BytesReference internalSourceRef()A byte representation of the source -
filter
Apply a filter to this source, returning a new Source -
extractValue
For the provided path, return its value in the source. Both array and object values can be returned.- Parameters:
path- the value's path in the source.nullValue- a value to return if the path exists, but the value is 'null'. This helps in distinguishing between a path that doesn't exist vs. a value of 'null'.- Returns:
- the value associated with the path in the source or 'null' if the path does not exist.
-
empty
An empty Source, represented as an empty map -
fromBytes
Build a Source from a bytes representation with an unknown XContentType -
fromBytes
Build a Source from a bytes representation with a known XContentType -
fromMap
Build a Source from a Map representation. Note thatnullis accepted as an input and interpreted as an empty map- Parameters:
map- the java Map to use as a sourcexContentType- the XContentType to serialize this source
-
lazy
Build a source lazily if one of its methods is called
-