java.lang.Object
org.elasticsearch.search.lookup.SourceLookup
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Provider for source using given source bytes.static class
Provider for source using a given map and optional content type.static class
Null source provider when we expect to be given a real source provider in the future.static class
Provider for source using a fields visitor.static interface
SourceProvider describes how SourceLookup will access the source. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) int
docId()
entrySet()
Returns the values associated with the path.extractValue
(String path, Object nullValue) For the provided path, return its value in the source.filter
(FetchSourceContext context) boolean
Checks if the source has been deserialized as aMap
of java objects.Internal source representation, might be compressed....boolean
isEmpty()
keySet()
void
void
setSegmentAndDocument
(org.apache.lucene.index.LeafReaderContext context, int docId) void
setSourceProvider
(SourceLookup.SourceProvider sourceProvider) int
size()
source()
Return the source as a map that will be unchanged when the lookup moves to a different document.sourceAsMap
(BytesReference source) Get the source as aMap
of java objects.values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
SourceLookup
-
-
Method Details
-
sourceContentType
-
docId
public int docId() -
source
Return the source as a map that will be unchanged when the lookup moves to a different document.Important: This can lose precision on numbers with a decimal point. It converts numbers like
"n": 1234.567
to adouble
which 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. -
setSourceProvider
-
setSegmentAndDocument
public void setSegmentAndDocument(org.apache.lucene.index.LeafReaderContext context, int docId) -
internalSourceRef
Internal source representation, might be compressed.... -
hasSourceAsMap
public boolean hasSourceAsMap()Checks if the source has been deserialized as aMap
of java objects. -
extractRawValuesWithoutCaching
Returns the values associated with the path. Those are "low" level values, and it can handle path expression where an array/list is navigated within. This method will: - not cache source if it's not already parsed - will only extract the desired values from the compressed source instead of deserializing the whole object This is useful when the caller only wants a single value from source and does not care of source is fully parsed and cached for later use.- Parameters:
path
- The path from which to extract the values from source- Returns:
- The list of found values or an empty list if none are found
-
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.
-
filter
-
sourceAsMap
public static Map<String,Object> sourceAsMap(BytesReference source) throws ElasticsearchParseException Get the source as aMap
of java objects.Important: This can lose precision on numbers with a decimal point. It converts numbers like
"n": 1234.567
to adouble
which 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.- Throws:
ElasticsearchParseException
-
get
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
Object>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
Object>
-
keySet
-
values
-
entrySet
-
put
-
remove
-
putAll
-
clear
public void clear()
-