Class SourceLookup

java.lang.Object
org.elasticsearch.search.lookup.SourceLookup
All Implemented Interfaces:
Map<String,Object>

public class SourceLookup extends Object implements Map<String,Object>
  • Constructor Details

    • SourceLookup

      public SourceLookup()
  • Method Details

    • sourceContentType

      public org.elasticsearch.xcontent.XContentType sourceContentType()
    • docId

      public int docId()
    • source

      public Map<String,Object> 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 a double 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.

    • sourceAsMap

      public static Map<String,Object> sourceAsMap(BytesReference source) throws ElasticsearchParseException
      Get the source as a Map of java objects.

      Important: This can lose precision on numbers with a decimal point. It converts numbers like "n": 1234.567 to a double 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
    • setSegmentAndDocument

      public void setSegmentAndDocument(org.apache.lucene.index.LeafReaderContext context, int docId)
    • setSource

      public void setSource(BytesReference source)
    • setSourceContentType

      public void setSourceContentType(org.elasticsearch.xcontent.XContentType sourceContentType)
    • setSource

      public void setSource(Map<String,Object> source)
    • internalSourceRef

      public BytesReference internalSourceRef()
      Internal source representation, might be compressed....
    • hasSourceAsMap

      public boolean hasSourceAsMap()
      Checks if the source has been deserialized as a Map of java objects.
    • extractRawValues

      public List<Object> extractRawValues(String path)
      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.
    • extractValue

      public Object extractValue(String path, @Nullable Object nullValue)
      For the provided path, return its value in the source. Note that in contrast with extractRawValues(java.lang.String), 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

      public Object filter(FetchSourceContext context)
    • get

      public Object get(Object key)
      Specified by:
      get in interface Map<String,Object>
    • size

      public int size()
      Specified by:
      size in interface Map<String,Object>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,Object>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,Object>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,Object>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,Object>
    • values

      public Collection<Object> values()
      Specified by:
      values in interface Map<String,Object>
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Specified by:
      entrySet in interface Map<String,Object>
    • put

      public Object put(String key, Object value)
      Specified by:
      put in interface Map<String,Object>
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Map<String,Object>
    • putAll

      public void putAll(Map<? extends String,? extends Object> m)
      Specified by:
      putAll in interface Map<String,Object>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,Object>