Class TopHitsAggregationBuilder
java.lang.Object
org.elasticsearch.search.aggregations.AggregationBuilder
org.elasticsearch.search.aggregations.AbstractAggregationBuilder<TopHitsAggregationBuilder>
org.elasticsearch.search.aggregations.metrics.TopHitsAggregationBuilder
- All Implemented Interfaces:
NamedWriteable,Writeable,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment,Rewriteable<AggregationBuilder>,BaseAggregationBuilder
public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHitsAggregationBuilder>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
AggregationBuilder.BucketCardinality, AggregationBuilder.CommonFieldsNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAMEFields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
metadataFields inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
factoriesBuilder, name -
Constructor Summary
Constructors Modifier Constructor Description TopHitsAggregationBuilder(java.lang.String name)TopHitsAggregationBuilder(StreamInput in)Read from a stream.protectedTopHitsAggregationBuilder(TopHitsAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metadata) -
Method Summary
Modifier and Type Method Description AggregationBuilder.BucketCardinalitybucketCardinality()A rough count of the number of buckets thatAggregators built by this builder will contain per owning parent bucket.protected org.elasticsearch.search.aggregations.metrics.TopHitsAggregatorFactorydoBuild(QueryShardContext queryShardContext, AggregatorFactory parent, AggregatorFactories.Builder subfactoriesBuilder)TopHitsAggregationBuilderdocValueField(java.lang.String docValueField)Adds a field to load from doc values and return as part of the search request.TopHitsAggregationBuilderdocValueField(java.lang.String docValueField, java.lang.String format)Adds a field to load from doc values and return as part of the search request.java.util.List<FieldAndFormat>docValueFields()Gets the field-data fields.protected voiddoWriteTo(StreamOutput out)booleanequals(java.lang.Object o)booleanexplain()Indicates whether each search hit will be returned with an explanation of the hit (ranking)TopHitsAggregationBuilderexplain(boolean explain)Should eachSearchHitbe returned with an explanation of the hit (ranking).TopHitsAggregationBuilderfetchField(java.lang.String field)Adds a field to load and return as part of the search request.TopHitsAggregationBuilderfetchField(java.lang.String field, java.lang.String format)Adds a field to load and return as part of the search request.java.util.List<FieldAndFormat>fetchFields()Gets the fields to load and return as part of the search request.FetchSourceContextfetchSource()Gets theFetchSourceContextwhich defines how the _source should be fetched.TopHitsAggregationBuilderfetchSource(boolean fetch)Indicates whether the response should contain the stored _source for every hitTopHitsAggregationBuilderfetchSource(java.lang.String[] includes, java.lang.String[] excludes)Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.TopHitsAggregationBuilderfetchSource(java.lang.String include, java.lang.String exclude)Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.TopHitsAggregationBuilderfetchSource(FetchSourceContext fetchSourceContext)Indicate how the _source should be fetched.intfrom()Gets the from index to start the search from.TopHitsAggregationBuilderfrom(int from)From index to start the search from.java.lang.StringgetType()The name of the type of aggregation built by this builder.inthashCode()HighlightBuilderhighlighter()Gets the highlighter builder for this request.TopHitsAggregationBuilderhighlighter(HighlightBuilder highlightBuilder)Adds highlight to perform as part of the search.protected org.elasticsearch.common.xcontent.XContentBuilderinternalXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)static TopHitsAggregationBuilderparse(java.lang.String aggregationName, org.elasticsearch.common.xcontent.XContentParser parser)TopHitsAggregationBuilderscriptField(java.lang.String name, Script script)Adds a script field under the given name with the provided script.TopHitsAggregationBuilderscriptField(java.lang.String name, Script script, boolean ignoreFailure)Adds a script field under the given name with the provided script.java.util.Set<SearchSourceBuilder.ScriptField>scriptFields()Gets the script fields.TopHitsAggregationBuilderscriptFields(java.util.List<SearchSourceBuilder.ScriptField> scriptFields)java.lang.BooleanseqNoAndPrimaryTerm()Indicates whetherSearchHits should be returned with the sequence number and primary term of the last modification of the document.TopHitsAggregationBuilderseqNoAndPrimaryTerm(java.lang.Boolean seqNoAndPrimaryTerm)Should eachSearchHitbe returned with the sequence number and primary term of the last modification of the document.protected AggregationBuildershallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metadata)Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetadata.intsize()Gets the number of search hits to return.TopHitsAggregationBuildersize(int size)The number of search hits to return.TopHitsAggregationBuildersort(java.lang.String name)Add a sort against the given field name.TopHitsAggregationBuildersort(java.lang.String name, SortOrder order)Adds a sort against the given field name and the sort ordering.TopHitsAggregationBuildersort(SortBuilder<?> sort)Adds a sort builder.java.util.List<SortBuilder<?>>sorts()Gets the bytes representing the sort builders for this request.TopHitsAggregationBuildersorts(java.util.List<SortBuilder<?>> sorts)Adds a sort builder.TopHitsAggregationBuilderstoredField(java.lang.String field)Adds a stored field to load and return (note, it must be stored) as part of the search request.StoredFieldsContextstoredFields()Gets the stored fields contextTopHitsAggregationBuilderstoredFields(java.util.List<java.lang.String> fields)Sets the stored fields to load and return as part of the search request.TopHitsAggregationBuildersubAggregations(AggregatorFactories.Builder subFactories)Registers sub-factories with this factory.booleantrackScores()Indicates whether scores will be tracked for this request.TopHitsAggregationBuildertrackScores(boolean trackScores)Applies when sorting, and controls if scores will be tracked as well.booleanversion()Indicates whether the document's version will be included in the search hits.TopHitsAggregationBuilderversion(boolean version)Should eachSearchHitbe returned with a version associated with it.Methods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
build, getMetadata, getWriteableName, setMetadata, subAggregation, subAggregation, toXContent, writeToMethods inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
buildPipelineTree, doRewrite, getName, getPipelineAggregations, getSubAggregations, rewrite, toString
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
-
Constructor Details
-
TopHitsAggregationBuilder
public TopHitsAggregationBuilder(java.lang.String name) -
TopHitsAggregationBuilder
protected TopHitsAggregationBuilder(TopHitsAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metadata) -
TopHitsAggregationBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
shallowCopy
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metadata)Description copied from class:AggregationBuilderCreate a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetadata. Used byAggregationBuilder.rewrite(QueryRewriteContext).- Specified by:
shallowCopyin classAggregationBuilder
-
doWriteTo
- Specified by:
doWriteToin classAbstractAggregationBuilder<TopHitsAggregationBuilder>- Throws:
java.io.IOException
-
from
From index to start the search from. Defaults to0. -
from
public int from()Gets the from index to start the search from. -
size
The number of search hits to return. Defaults to10. -
size
public int size()Gets the number of search hits to return. -
sort
Adds a sort against the given field name and the sort ordering.- Parameters:
name- The name of the fieldorder- The sort ordering
-
sort
Add a sort against the given field name.- Parameters:
name- The name of the field to sort by
-
sort
Adds a sort builder. -
sorts
Adds a sort builder. -
sorts
Gets the bytes representing the sort builders for this request. -
highlighter
Adds highlight to perform as part of the search. -
highlighter
Gets the highlighter builder for this request. -
fetchSource
Indicates whether the response should contain the stored _source for every hit -
fetchSource
public TopHitsAggregationBuilder fetchSource(@Nullable java.lang.String include, @Nullable java.lang.String exclude)Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.- Parameters:
include- An optional include (optionally wildcarded) pattern to filter the returned _sourceexclude- An optional exclude (optionally wildcarded) pattern to filter the returned _source
-
fetchSource
public TopHitsAggregationBuilder fetchSource(@Nullable java.lang.String[] includes, @Nullable java.lang.String[] excludes)Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.- Parameters:
includes- An optional list of include (optionally wildcarded) pattern to filter the returned _sourceexcludes- An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
-
fetchSource
Indicate how the _source should be fetched. -
fetchSource
Gets theFetchSourceContextwhich defines how the _source should be fetched. -
storedField
Adds a stored field to load and return (note, it must be stored) as part of the search request. To disable the stored fields entirely (source and metadata fields) usestoredField("_none_"). -
storedFields
Sets the stored fields to load and return as part of the search request. To disable the stored fields entirely (source and metadata fields) usestoredField("_none_"). -
storedFields
Gets the stored fields context -
docValueField
public TopHitsAggregationBuilder docValueField(java.lang.String docValueField, java.lang.String format)Adds a field to load from doc values and return as part of the search request. -
docValueField
Adds a field to load from doc values and return as part of the search request. -
docValueFields
Gets the field-data fields. -
fetchField
Adds a field to load and return as part of the search request. -
fetchField
Adds a field to load and return as part of the search request. -
fetchFields
Gets the fields to load and return as part of the search request. -
scriptField
Adds a script field under the given name with the provided script.- Parameters:
name- The name of the fieldscript- The script
-
scriptField
public TopHitsAggregationBuilder scriptField(java.lang.String name, Script script, boolean ignoreFailure)Adds a script field under the given name with the provided script.- Parameters:
name- The name of the fieldscript- The script
-
scriptFields
public TopHitsAggregationBuilder scriptFields(java.util.List<SearchSourceBuilder.ScriptField> scriptFields) -
scriptFields
Gets the script fields. -
explain
Should eachSearchHitbe returned with an explanation of the hit (ranking). -
explain
public boolean explain()Indicates whether each search hit will be returned with an explanation of the hit (ranking) -
version
Should eachSearchHitbe returned with a version associated with it. -
version
public boolean version()Indicates whether the document's version will be included in the search hits. -
seqNoAndPrimaryTerm
Should eachSearchHitbe returned with the sequence number and primary term of the last modification of the document. -
seqNoAndPrimaryTerm
public java.lang.Boolean seqNoAndPrimaryTerm()Indicates whetherSearchHits should be returned with the sequence number and primary term of the last modification of the document. -
trackScores
Applies when sorting, and controls if scores will be tracked as well. Defaults tofalse. -
trackScores
public boolean trackScores()Indicates whether scores will be tracked for this request. -
subAggregations
Description copied from class:AbstractAggregationBuilderRegisters sub-factories with this factory. The sub-factory will be responsible for the creation of sub-aggregators under the aggregator created by this factory.- Specified by:
subAggregationsin interfaceBaseAggregationBuilder- Overrides:
subAggregationsin classAbstractAggregationBuilder<TopHitsAggregationBuilder>- Parameters:
subFactories- The sub-factories- Returns:
- this factory (fluent interface)
-
bucketCardinality
Description copied from class:AggregationBuilderA rough count of the number of buckets thatAggregators built by this builder will contain per owning parent bucket.- Specified by:
bucketCardinalityin classAggregationBuilder
-
doBuild
protected org.elasticsearch.search.aggregations.metrics.TopHitsAggregatorFactory doBuild(QueryShardContext queryShardContext, AggregatorFactory parent, AggregatorFactories.Builder subfactoriesBuilder) throws java.io.IOException- Specified by:
doBuildin classAbstractAggregationBuilder<TopHitsAggregationBuilder>- Throws:
java.io.IOException
-
internalXContent
protected org.elasticsearch.common.xcontent.XContentBuilder internalXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
internalXContentin classAbstractAggregationBuilder<TopHitsAggregationBuilder>- Throws:
java.io.IOException
-
parse
public static TopHitsAggregationBuilder parse(java.lang.String aggregationName, org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classAbstractAggregationBuilder<TopHitsAggregationBuilder>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractAggregationBuilder<TopHitsAggregationBuilder>
-
getType
public java.lang.String getType()Description copied from interface:BaseAggregationBuilderThe name of the type of aggregation built by this builder.
-