Class NestedQueryBuilder

java.lang.Object
org.elasticsearch.index.query.AbstractQueryBuilder<NestedQueryBuilder>
org.elasticsearch.index.query.NestedQueryBuilder
All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, QueryBuilder, Rewriteable<QueryBuilder>

public class NestedQueryBuilder
extends AbstractQueryBuilder<NestedQueryBuilder>
  • Field Details

    • NAME

      public static final java.lang.String NAME
      See Also:
      Constant Field Values
    • DEFAULT_IGNORE_UNMAPPED

      public static final boolean DEFAULT_IGNORE_UNMAPPED
      The default value for ignore_unmapped.
      See Also:
      Constant Field Values
  • Constructor Details

    • NestedQueryBuilder

      public NestedQueryBuilder​(java.lang.String path, QueryBuilder query, org.apache.lucene.search.join.ScoreMode scoreMode)
    • NestedQueryBuilder

      public NestedQueryBuilder​(StreamInput in) throws java.io.IOException
      Read from a stream.
      Throws:
      java.io.IOException
  • Method Details

    • doWriteTo

      protected void doWriteTo​(StreamOutput out) throws java.io.IOException
      Specified by:
      doWriteTo in class AbstractQueryBuilder<NestedQueryBuilder>
      Throws:
      java.io.IOException
    • query

      public QueryBuilder query()
      Returns the nested query to execute.
    • innerHit

      public InnerHitBuilder innerHit()
      Returns inner hit definition in the scope of this query and reusing the defined type and query.
    • innerHit

      public NestedQueryBuilder innerHit​(InnerHitBuilder innerHitBuilder)
    • scoreMode

      public org.apache.lucene.search.join.ScoreMode scoreMode()
      Returns how the scores from the matching child documents are mapped into the nested parent document.
    • ignoreUnmapped

      public NestedQueryBuilder ignoreUnmapped​(boolean ignoreUnmapped)
      Sets whether the query builder should ignore unmapped paths (and run a MatchNoDocsQuery in place of this query) or throw an exception if the path is unmapped.
    • ignoreUnmapped

      public boolean ignoreUnmapped()
      Gets whether the query builder will ignore unmapped fields (and run a MatchNoDocsQuery in place of this query) or throw an exception if the path is unmapped.
    • doXContent

      protected void doXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      doXContent in class AbstractQueryBuilder<NestedQueryBuilder>
      Throws:
      java.io.IOException
    • fromXContent

      public static NestedQueryBuilder fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException
      Throws:
      java.io.IOException
    • parseScoreMode

      public static org.apache.lucene.search.join.ScoreMode parseScoreMode​(java.lang.String scoreModeString)
    • scoreModeAsString

      public static java.lang.String scoreModeAsString​(org.apache.lucene.search.join.ScoreMode scoreMode)
    • getWriteableName

      public final java.lang.String getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object
    • doEquals

      protected boolean doEquals​(NestedQueryBuilder that)
      Description copied from class: AbstractQueryBuilder
      Indicates whether some other QueryBuilder object of the same type is "equal to" this one.
      Specified by:
      doEquals in class AbstractQueryBuilder<NestedQueryBuilder>
    • doHashCode

      protected int doHashCode()
      Specified by:
      doHashCode in class AbstractQueryBuilder<NestedQueryBuilder>
    • doToQuery

      protected org.apache.lucene.search.Query doToQuery​(SearchExecutionContext context) throws java.io.IOException
      Specified by:
      doToQuery in class AbstractQueryBuilder<NestedQueryBuilder>
      Throws:
      java.io.IOException
    • doRewrite

      protected QueryBuilder doRewrite​(QueryRewriteContext queryRewriteContext) throws java.io.IOException
      Overrides:
      doRewrite in class AbstractQueryBuilder<NestedQueryBuilder>
      Throws:
      java.io.IOException
    • extractInnerHitBuilders

      public void extractInnerHitBuilders​(java.util.Map<java.lang.String,​InnerHitContextBuilder> innerHits)
      Description copied from class: AbstractQueryBuilder
      For internal usage only! Extracts the inner hits from the query tree. While it extracts inner hits, child inner hits are inlined into the inner hit builder they belong to.
      Overrides:
      extractInnerHitBuilders in class AbstractQueryBuilder<NestedQueryBuilder>