Class SearchHit.NestedIdentity

java.lang.Object
org.elasticsearch.search.SearchHit.NestedIdentity
All Implemented Interfaces:
Writeable, ToXContent, ToXContentFragment
Enclosing class:
SearchHit

public static final class SearchHit.NestedIdentity extends Object implements Writeable, ToXContentFragment
Encapsulates the nested identity of a hit.
  • Constructor Details

  • Method Details

    • getField

      public Text getField()
      Returns the nested field in the source this hit originates from
    • getOffset

      public int getOffset()
      Returns the offset in the nested array of objects in the source this hit
    • getChild

      public SearchHit.NestedIdentity getChild()
      Returns the next child nested level if there is any, otherwise null is returned. In the case of mappings with multiple levels of nested object fields
    • extractSource

      public Source extractSource(Source root)
      Extracts the part of the root source that applies to this particular NestedIdentity, while preserving the enclosing path structure. For a root document that looks like this: { "children" : [ { "grandchildren" : [ { "field" : "value1" }, { "field" : "value2" } ] }, { "grandchildren" : [ { "field" : "value3" }, { "field" : "value4" } ] } ] } Extracting the NestedIdentity of the first child and second grandchild results in a source that looks like this: { "children" : { "grandchildren" : { "field" : "value2" } } } If the relevant child source object does not exist in the root, then we return Source.empty(XContentType)
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromXContent

      public static SearchHit.NestedIdentity fromXContent(XContentParser parser)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object