Module org.elasticsearch.server
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
,VersionedNamedWriteable
,Writeable
,Rewriteable<AggregationBuilder>
,BaseAggregationBuilder
,ToXContent
,ToXContentFragment
public class TopHitsAggregationBuilder
extends AbstractAggregationBuilder<TopHitsAggregationBuilder>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
AggregationBuilder.BucketCardinality, AggregationBuilder.CommonFields
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsFields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
metadata
Fields inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
DEFAULT_PREALLOCATION, factoriesBuilder, name
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionRead from a stream.protected
TopHitsAggregationBuilder
(TopHitsAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) -
Method Summary
Modifier and TypeMethodDescriptionA rough count of the number of buckets thatAggregator
s built by this builder will contain per owning parent bucket.protected org.elasticsearch.search.aggregations.metrics.TopHitsAggregatorFactory
doBuild
(AggregationContext context, AggregatorFactory parent, AggregatorFactories.Builder subfactoriesBuilder) docValueField
(String docValueField) Adds a field to load from doc values and return as part of the search request.docValueField
(String docValueField, String format) Adds a field to load from doc values and return as part of the search request.protected void
doWriteTo
(StreamOutput out) boolean
explain
(boolean explain) Should eachSearchHit
be returned with an explanation of the hit (ranking).fetchField
(String field) Adds a field to load and return as part of the search request.fetchField
(FieldAndFormat fieldAndFormat) Adds a field to load and return as part of the search request.fetchSource
(String[] includes, String[] excludes) Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.fetchSource
(String include, String exclude) Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.fetchSource
(FetchSourceContext fetchSourceContext) Indicate how the _source should be fetched.int
from()
Gets the from index to start the search from.from
(int from) From index to start the search from.The minimal version of the recipient this object can be sent togetType()
The name of the type of aggregation built by this builder.int
hashCode()
highlighter
(HighlightBuilder highlightBuilder) Adds highlight to perform as part of the search.protected XContentBuilder
internalXContent
(XContentBuilder builder, ToXContent.Params params) static TopHitsAggregationBuilder
parse
(String aggregationName, XContentParser parser) scriptField
(String name, Script script) Adds a script field under the given name with the provided script.scriptField
(String name, Script script, boolean ignoreFailure) Adds a script field under the given name with the provided script.scriptFields
(List<SearchSourceBuilder.ScriptField> scriptFields) seqNoAndPrimaryTerm
(Boolean seqNoAndPrimaryTerm) Should eachSearchHit
be returned with the sequence number and primary term of the last modification of the document.protected AggregationBuilder
shallowCopy
(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilder
andmetadata
.int
size()
Gets the number of search hits to return.size
(int size) The number of search hits to return.Add a sort against the given field name.Adds a sort against the given field name and the sort ordering.sort
(SortBuilder<?> sort) Adds a sort builder.sorts
(List<SortBuilder<?>> sorts) Adds a sort builder.storedField
(String field) Adds a stored field to load and return (note, it must be stored) as part of the search request.storedFields
(List<String> fields) Sets the stored fields to load and return as part of the search request.subAggregations
(AggregatorFactories.Builder subFactories) Registers sub-factories with this factory.boolean
Does this aggregation support running with in a sampling context.trackScores
(boolean trackScores) Applies when sorting, and controls if scores will be tracked as well.version
(boolean version) Should eachSearchHit
be returned with a version associated with it.Methods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
build, getMetadata, getWriteableName, setMetadata, subAggregation, subAggregation, toXContent, writeTo
Methods inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
buildPipelineTree, bytesToPreallocate, deepCopy, doRewrite, getName, getOutputFieldNames, getPipelineAggregations, getQuery, getSubAggregations, isInSortOrderExecutionRequired, rewrite, supportsParallelCollection, toString, validateSequentiallyOrdered, validateSequentiallyOrderedWithoutGaps
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
TopHitsAggregationBuilder
-
TopHitsAggregationBuilder
protected TopHitsAggregationBuilder(TopHitsAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) -
TopHitsAggregationBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
shallowCopy
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) Description copied from class:AggregationBuilder
Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilder
andmetadata
.- Specified by:
shallowCopy
in classAggregationBuilder
-
doWriteTo
- Specified by:
doWriteTo
in classAbstractAggregationBuilder<TopHitsAggregationBuilder>
- Throws:
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. -
highlighter
Adds highlight to perform as part of the search. -
fetchSource
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 String[] includes, @Nullable 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. -
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_")
. -
docValueField
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. -
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. -
scriptField
Adds a script field under the given name with the provided script.- Parameters:
name
- The name of the fieldscript
- The script
-
scriptField
Adds a script field under the given name with the provided script.- Parameters:
name
- The name of the fieldscript
- The script
-
scriptFields
-
explain
Should eachSearchHit
be returned with an explanation of the hit (ranking). -
version
Should eachSearchHit
be returned with a version associated with it. -
seqNoAndPrimaryTerm
Should eachSearchHit
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
. -
subAggregations
Description copied from class:AbstractAggregationBuilder
Registers 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:
subAggregations
in interfaceBaseAggregationBuilder
- Overrides:
subAggregations
in classAbstractAggregationBuilder<TopHitsAggregationBuilder>
- Parameters:
subFactories
- The sub-factories- Returns:
- this factory (fluent interface)
-
supportsSampling
public boolean supportsSampling()Description copied from class:AggregationBuilder
Does this aggregation support running with in a sampling context. By default, it's false for all aggregations. If the sub-classed builder supports sampling, be sure of the following that the resulting internal aggregation objects override theInternalAggregation.finalizeSampling(SamplingContext)
and scales any values that require scaling.- Overrides:
supportsSampling
in classAggregationBuilder
- Returns:
- does this aggregation builder support sampling
-
bucketCardinality
Description copied from class:AggregationBuilder
A rough count of the number of buckets thatAggregator
s built by this builder will contain per owning parent bucket.- Specified by:
bucketCardinality
in classAggregationBuilder
-
doBuild
protected org.elasticsearch.search.aggregations.metrics.TopHitsAggregatorFactory doBuild(AggregationContext context, AggregatorFactory parent, AggregatorFactories.Builder subfactoriesBuilder) throws IOException - Specified by:
doBuild
in classAbstractAggregationBuilder<TopHitsAggregationBuilder>
- Throws:
IOException
-
internalXContent
protected XContentBuilder internalXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
internalXContent
in classAbstractAggregationBuilder<TopHitsAggregationBuilder>
- Throws:
IOException
-
parse
public static TopHitsAggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException - Throws:
IOException
-
equals
- Overrides:
equals
in classAbstractAggregationBuilder<TopHitsAggregationBuilder>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractAggregationBuilder<TopHitsAggregationBuilder>
-
getType
Description copied from interface:BaseAggregationBuilder
The name of the type of aggregation built by this builder. -
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteable
The minimal version of the recipient this object can be sent to
-