NamedWriteable
, Writeable
, ToXContent
, ToXContentFragment
, BaseAggregationBuilder
public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHitsAggregationBuilder>
AggregationBuilder.CommonFields
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Writeable.Reader<V>, Writeable.Writer<V>
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
NAME |
metaData
factoriesBuilder, name
EMPTY_PARAMS
Modifier | Constructor | Description |
---|---|---|
|
TopHitsAggregationBuilder(java.lang.String name) |
|
|
TopHitsAggregationBuilder(StreamInput in) |
Read from a stream.
|
protected |
TopHitsAggregationBuilder(TopHitsAggregationBuilder clone,
AggregatorFactories.Builder factoriesBuilder,
java.util.Map<java.lang.String,java.lang.Object> metaData) |
Modifier and Type | Method | Description |
---|---|---|
protected TopHitsAggregatorFactory |
doBuild(SearchContext context,
AggregatorFactory<?> parent,
AggregatorFactories.Builder subfactoriesBuilder) |
|
protected boolean |
doEquals(java.lang.Object obj) |
|
protected int |
doHashCode() |
|
protected void |
doWriteTo(StreamOutput out) |
|
boolean |
explain() |
Indicates whether each search hit will be returned with an
explanation of the hit (ranking)
|
TopHitsAggregationBuilder |
explain(boolean explain) |
Should each
SearchHit be returned
with an explanation of the hit (ranking). |
FetchSourceContext |
fetchSource() |
Gets the
FetchSourceContext which defines how the _source
should be fetched. |
TopHitsAggregationBuilder |
fetchSource(boolean fetch) |
Indicates whether the response should contain the stored _source for
every hit
|
TopHitsAggregationBuilder |
fetchSource(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.
|
TopHitsAggregationBuilder |
fetchSource(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.
|
TopHitsAggregationBuilder |
fetchSource(FetchSourceContext fetchSourceContext) |
Indicate how the _source should be fetched.
|
TopHitsAggregationBuilder |
fieldDataField(java.lang.String fieldDataField) |
Adds a field to load from the field data cache and return as part of
the search request.
|
java.util.List<java.lang.String> |
fieldDataFields() |
Gets the field-data fields.
|
TopHitsAggregationBuilder |
fieldDataFields(java.util.List<java.lang.String> fieldDataFields) |
Adds fields to load from the field data cache and return as part of
the search request.
|
int |
from() |
Gets the from index to start the search from.
|
TopHitsAggregationBuilder |
from(int from) |
From index to start the search from.
|
java.lang.String |
getType() |
The name of the type of aggregation built by this builder.
|
HighlightBuilder |
highlighter() |
Gets the highlighter builder for this request.
|
TopHitsAggregationBuilder |
highlighter(HighlightBuilder highlightBuilder) |
Adds highlight to perform as part of the search.
|
protected XContentBuilder |
internalXContent(XContentBuilder builder,
ToXContent.Params params) |
|
static TopHitsAggregationBuilder |
parse(java.lang.String aggregationName,
XContentParser parser) |
|
TopHitsAggregationBuilder |
scriptField(java.lang.String name,
Script script) |
Adds a script field under the given name with the provided script.
|
TopHitsAggregationBuilder |
scriptField(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.
|
TopHitsAggregationBuilder |
scriptFields(java.util.List<SearchSourceBuilder.ScriptField> scriptFields) |
|
protected AggregationBuilder |
shallowCopy(AggregatorFactories.Builder factoriesBuilder,
java.util.Map<java.lang.String,java.lang.Object> metaData) |
Create a shallow copy of this builder and replacing
AggregationBuilder.factoriesBuilder and metaData . |
int |
size() |
Gets the number of search hits to return.
|
TopHitsAggregationBuilder |
size(int size) |
The number of search hits to return.
|
TopHitsAggregationBuilder |
sort(java.lang.String name) |
Add a sort against the given field name.
|
TopHitsAggregationBuilder |
sort(java.lang.String name,
SortOrder order) |
Adds a sort against the given field name and the sort ordering.
|
TopHitsAggregationBuilder |
sort(SortBuilder<?> sort) |
Adds a sort builder.
|
java.util.List<SortBuilder<?>> |
sorts() |
Gets the bytes representing the sort builders for this request.
|
TopHitsAggregationBuilder |
sorts(java.util.List<SortBuilder<?>> sorts) |
Adds a sort builder.
|
TopHitsAggregationBuilder |
storedField(java.lang.String field) |
Adds a stored field to load and return (note, it must be stored) as part of the search request.
|
StoredFieldsContext |
storedFields() |
Gets the stored fields context
|
TopHitsAggregationBuilder |
storedFields(java.util.List<java.lang.String> fields) |
Sets the stored fields to load and return as part of the search request.
|
TopHitsAggregationBuilder |
subAggregations(AggregatorFactories.Builder subFactories) |
Registers sub-factories with this factory.
|
boolean |
trackScores() |
Indicates whether scores will be tracked for this request.
|
TopHitsAggregationBuilder |
trackScores(boolean trackScores) |
Applies when sorting, and controls if scores will be tracked as well.
|
boolean |
version() |
Indicates whether the document's version will be included in the
search hits.
|
TopHitsAggregationBuilder |
version(boolean version) |
Should each
SearchHit be returned
with a version associated with it. |
build, equals, getMetaData, getWriteableName, hashCode, setMetaData, subAggregation, subAggregation, toXContent, writeTo
doRewrite, getName, getPipelineAggregations, getSubAggregations, rewrite, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isFragment
public static final java.lang.String NAME
public TopHitsAggregationBuilder(java.lang.String name)
protected TopHitsAggregationBuilder(TopHitsAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData)
public TopHitsAggregationBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData)
AggregationBuilder
AggregationBuilder.factoriesBuilder
and metaData
.
Used by AggregationBuilder.rewrite(QueryRewriteContext)
.shallowCopy
in class AggregationBuilder
protected void doWriteTo(StreamOutput out) throws java.io.IOException
doWriteTo
in class AbstractAggregationBuilder<TopHitsAggregationBuilder>
java.io.IOException
public TopHitsAggregationBuilder from(int from)
public int from()
public TopHitsAggregationBuilder size(int size)
public int size()
public TopHitsAggregationBuilder sort(java.lang.String name, SortOrder order)
name
- The name of the fieldorder
- The sort orderingpublic TopHitsAggregationBuilder sort(java.lang.String name)
name
- The name of the field to sort bypublic TopHitsAggregationBuilder sort(SortBuilder<?> sort)
public TopHitsAggregationBuilder sorts(java.util.List<SortBuilder<?>> sorts)
public java.util.List<SortBuilder<?>> sorts()
public TopHitsAggregationBuilder highlighter(HighlightBuilder highlightBuilder)
public HighlightBuilder highlighter()
public TopHitsAggregationBuilder fetchSource(boolean fetch)
public TopHitsAggregationBuilder fetchSource(@Nullable java.lang.String include, @Nullable java.lang.String exclude)
include
- An optional include (optionally wildcarded) pattern to
filter the returned _sourceexclude
- An optional exclude (optionally wildcarded) pattern to
filter the returned _sourcepublic TopHitsAggregationBuilder fetchSource(@Nullable java.lang.String[] includes, @Nullable java.lang.String[] excludes)
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 _sourcepublic TopHitsAggregationBuilder fetchSource(@Nullable FetchSourceContext fetchSourceContext)
public FetchSourceContext fetchSource()
FetchSourceContext
which defines how the _source
should be fetched.public TopHitsAggregationBuilder storedField(java.lang.String field)
storedField("_none_")
.public TopHitsAggregationBuilder storedFields(java.util.List<java.lang.String> fields)
storedField("_none_")
.public StoredFieldsContext storedFields()
public TopHitsAggregationBuilder fieldDataField(java.lang.String fieldDataField)
public TopHitsAggregationBuilder fieldDataFields(java.util.List<java.lang.String> fieldDataFields)
public java.util.List<java.lang.String> fieldDataFields()
public TopHitsAggregationBuilder scriptField(java.lang.String name, Script script)
name
- The name of the fieldscript
- The scriptpublic TopHitsAggregationBuilder scriptField(java.lang.String name, Script script, boolean ignoreFailure)
name
- The name of the fieldscript
- The scriptpublic TopHitsAggregationBuilder scriptFields(java.util.List<SearchSourceBuilder.ScriptField> scriptFields)
public java.util.Set<SearchSourceBuilder.ScriptField> scriptFields()
public TopHitsAggregationBuilder explain(boolean explain)
SearchHit
be returned
with an explanation of the hit (ranking).public boolean explain()
public TopHitsAggregationBuilder version(boolean version)
SearchHit
be returned
with a version associated with it.public boolean version()
public TopHitsAggregationBuilder trackScores(boolean trackScores)
public boolean trackScores()
public TopHitsAggregationBuilder subAggregations(AggregatorFactories.Builder subFactories)
AbstractAggregationBuilder
subAggregations
in interface BaseAggregationBuilder
subAggregations
in class AbstractAggregationBuilder<TopHitsAggregationBuilder>
subFactories
- The sub-factoriesprotected TopHitsAggregatorFactory doBuild(SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subfactoriesBuilder) throws java.io.IOException
doBuild
in class AbstractAggregationBuilder<TopHitsAggregationBuilder>
java.io.IOException
protected XContentBuilder internalXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
internalXContent
in class AbstractAggregationBuilder<TopHitsAggregationBuilder>
java.io.IOException
public static TopHitsAggregationBuilder parse(java.lang.String aggregationName, XContentParser parser) throws java.io.IOException
java.io.IOException
protected int doHashCode()
doHashCode
in class AbstractAggregationBuilder<TopHitsAggregationBuilder>
protected boolean doEquals(java.lang.Object obj)
doEquals
in class AbstractAggregationBuilder<TopHitsAggregationBuilder>
public java.lang.String getType()
BaseAggregationBuilder