public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHitsAggregationBuilder>
AggregationBuilder.CommonFields
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
metaData
factoriesBuilder, name, type
EMPTY_PARAMS
Constructor and Description |
---|
TopHitsAggregationBuilder(StreamInput in)
Read from a stream.
|
TopHitsAggregationBuilder(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
protected TopHitsAggregatorFactory |
doBuild(AggregationContext 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(FetchSourceContext fetchSourceContext)
Indicate how the _source should be fetched.
|
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 |
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 |
getWriteableName()
Returns the name of the writeable object
|
HighlightBuilder |
highlighter()
Gets the hightlighter 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,
QueryParseContext context) |
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) |
int |
size()
Gets the number of search hits to return.
|
TopHitsAggregationBuilder |
size(int size)
The number of search hits to return.
|
TopHitsAggregationBuilder |
sort(SortBuilder<?> sort)
Adds a sort builder.
|
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.
|
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, getType, hashCode, setMetaData, subAggregation, subAggregation, toXContent, writeTo
getName
buildAsBytes, buildAsBytes, toString, toString
public static final java.lang.String NAME
public TopHitsAggregationBuilder(java.lang.String name)
public TopHitsAggregationBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
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 class AbstractAggregationBuilder<TopHitsAggregationBuilder>
subFactories
- The sub-factoriesprotected TopHitsAggregatorFactory doBuild(AggregationContext 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, QueryParseContext context) 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 getWriteableName()
NamedWriteable