public class SearchSourceBuilder extends ToXContentToBytes
searchSource()
.ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
EMPTY_PARAMS
Constructor and Description |
---|
SearchSourceBuilder()
Constructs a new search source builder.
|
Modifier and Type | Method and Description |
---|---|
SearchSourceBuilder |
addRescorer(RescoreBuilder rescoreBuilder) |
SearchSourceBuilder |
aggregation(AbstractAggregationBuilder aggregation)
Add an get to perform as part of the search.
|
SearchSourceBuilder |
aggregations(byte[] aggregationsBinary)
Sets a raw (xcontent / json) addAggregation.
|
SearchSourceBuilder |
aggregations(byte[] aggregationsBinary,
int aggregationsBinaryOffset,
int aggregationsBinaryLength)
Sets a raw (xcontent / json) addAggregation.
|
SearchSourceBuilder |
aggregations(BytesReference aggregationsBinary)
Sets a raw (xcontent / json) addAggregation.
|
SearchSourceBuilder |
aggregations(Map aggregations)
Sets a raw (xcontent / json) addAggregation.
|
SearchSourceBuilder |
aggregations(XContentBuilder aggs)
Sets a raw (xcontent / json) addAggregation.
|
SearchSourceBuilder |
clearRescorers() |
SearchSourceBuilder |
defaultRescoreWindowSize(int defaultRescoreWindowSize)
Deprecated.
use
RescoreBuilder.windowSize(int) instead. |
SearchSourceBuilder |
explain(Boolean explain)
Should each
SearchHit be returned with
an explanation of the hit (ranking). |
SearchSourceBuilder |
fetchSource(boolean fetch)
Indicates whether the response should contain the stored _source for
every hit
|
SearchSourceBuilder |
fetchSource(FetchSourceContext fetchSourceContext)
Indicate how the _source should be fetched.
|
SearchSourceBuilder |
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.
|
SearchSourceBuilder |
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.
|
SearchSourceBuilder |
field(String name)
Adds a field to load and return (note, it must be stored) as part of the
search request.
|
SearchSourceBuilder |
fieldDataField(String name)
Adds a field to load from the field data cache and return as part of the
search request.
|
SearchSourceBuilder |
fields(List<String> fields)
Sets the fields to load and return as part of the search request.
|
SearchSourceBuilder |
fields(String... fields)
Adds the fields to load and return as part of the search request.
|
SearchSourceBuilder |
from(int from)
From index to start the search from.
|
static HighlightBuilder |
highlight()
A static factory method to construct new search highlights.
|
SearchSourceBuilder |
highlight(HighlightBuilder highlightBuilder)
Adds highlight to perform as part of the search.
|
HighlightBuilder |
highlighter() |
SearchSourceBuilder |
indexBoost(String index,
float indexBoost)
Sets the boost a specific index will receive when the query is executeed
against it.
|
InnerHitsBuilder |
innerHitsBuilder() |
void |
innerToXContent(XContentBuilder builder,
ToXContent.Params params) |
SearchSourceBuilder |
minScore(float minScore)
Sets the minimum score below which docs will be filtered out.
|
SearchSourceBuilder |
noFields()
Sets no fields to be loaded, resulting in only id and type to be returned
per field.
|
SearchSourceBuilder |
postFilter(byte[] postFilter)
Sets a filter on the query executed that only applies to the search query
(and not aggs for example).
|
SearchSourceBuilder |
postFilter(byte[] postFilterBinary,
int postFilterBinaryOffset,
int postFilterBinaryLength)
Sets a filter on the query executed that only applies to the search query
(and not aggs for example).
|
SearchSourceBuilder |
postFilter(BytesReference postFilterBinary)
Sets a filter on the query executed that only applies to the search query
(and not aggs for example).
|
SearchSourceBuilder |
postFilter(Map postFilter)
Constructs a new search source builder with a query from a map.
|
SearchSourceBuilder |
postFilter(QueryBuilder postFilter)
Sets a filter that will be executed after the query has been executed and
only has affect on the search hits (not aggregations).
|
SearchSourceBuilder |
postFilter(String postFilterString)
Sets a filter on the query executed that only applies to the search query
(and not aggs for example).
|
SearchSourceBuilder |
postFilter(XContentBuilder postFilter)
Constructs a new search source builder with a query from a builder.
|
boolean |
profile()
Return whether to profile query execution, or
null if
unspecified. |
SearchSourceBuilder |
profile(boolean profile)
Should the query be profiled.
|
SearchSourceBuilder |
query(byte[] queryBinary)
Constructs a new search source builder with a raw search query.
|
SearchSourceBuilder |
query(byte[] queryBinary,
int queryBinaryOffset,
int queryBinaryLength)
Constructs a new search source builder with a raw search query.
|
SearchSourceBuilder |
query(BytesReference queryBinary)
Constructs a new search source builder with a raw search query.
|
SearchSourceBuilder |
query(Map query)
Constructs a new search source builder with a query from a map.
|
SearchSourceBuilder |
query(QueryBuilder query)
Constructs a new search source builder with a search query.
|
SearchSourceBuilder |
query(QuerySourceBuilder querySourceBuilder)
Sets the query provided as a
QuerySourceBuilder |
SearchSourceBuilder |
query(String queryString)
Constructs a new search source builder with a raw search query.
|
SearchSourceBuilder |
query(XContentBuilder query)
Constructs a new search source builder with a query from a builder.
|
SearchSourceBuilder |
scriptField(String name,
Script script)
Adds a script field under the given name with the provided script.
|
static SearchSourceBuilder |
searchSource()
A static factory method to construct a new search source.
|
SearchSourceBuilder |
size(int size)
The number of search hits to return.
|
SearchSourceBuilder |
sort(SortBuilder sort)
Adds a sort builder.
|
SearchSourceBuilder |
sort(String name)
Add a sort against the given field name.
|
SearchSourceBuilder |
sort(String name,
SortOrder order)
Adds a sort against the given field name and the sort ordering.
|
SearchSourceBuilder |
stats(String... statsGroups)
The stats groups this request will be aggregated under.
|
SuggestBuilder |
suggest() |
SearchSourceBuilder |
terminateAfter(int terminateAfter)
An optional terminate_after to terminate the search after collecting
terminateAfter documents |
SearchSourceBuilder |
timeout(String timeout)
An optional timeout to control how long search is allowed to take.
|
SearchSourceBuilder |
timeout(TimeValue timeout)
An optional timeout to control how long search is allowed to take.
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
SearchSourceBuilder |
trackScores(boolean trackScores)
Applies when sorting, and controls if scores will be tracked as well.
|
SearchSourceBuilder |
version(Boolean version)
Should each
SearchHit be returned with a
version associated with it. |
buildAsBytes, buildAsBytes, toString
public SearchSourceBuilder()
public static SearchSourceBuilder searchSource()
public static HighlightBuilder highlight()
public SearchSourceBuilder query(QuerySourceBuilder querySourceBuilder)
QuerySourceBuilder
public SearchSourceBuilder query(QueryBuilder query)
QueryBuilders
public SearchSourceBuilder query(byte[] queryBinary)
public SearchSourceBuilder query(byte[] queryBinary, int queryBinaryOffset, int queryBinaryLength)
public SearchSourceBuilder query(BytesReference queryBinary)
public SearchSourceBuilder query(String queryString)
public SearchSourceBuilder query(XContentBuilder query)
public SearchSourceBuilder query(Map query)
public SearchSourceBuilder postFilter(QueryBuilder postFilter)
public SearchSourceBuilder postFilter(String postFilterString)
public SearchSourceBuilder postFilter(byte[] postFilter)
public SearchSourceBuilder postFilter(byte[] postFilterBinary, int postFilterBinaryOffset, int postFilterBinaryLength)
public SearchSourceBuilder postFilter(BytesReference postFilterBinary)
public SearchSourceBuilder postFilter(XContentBuilder postFilter)
public SearchSourceBuilder postFilter(Map postFilter)
public SearchSourceBuilder from(int from)
public SearchSourceBuilder size(int size)
public SearchSourceBuilder minScore(float minScore)
public SearchSourceBuilder explain(Boolean explain)
SearchHit
be returned with
an explanation of the hit (ranking).public SearchSourceBuilder version(Boolean version)
SearchHit
be returned with a
version associated with it.public SearchSourceBuilder timeout(TimeValue timeout)
public SearchSourceBuilder timeout(String timeout)
public SearchSourceBuilder terminateAfter(int terminateAfter)
terminateAfter
documentspublic SearchSourceBuilder sort(String name, SortOrder order)
name
- The name of the fieldorder
- The sort orderingpublic SearchSourceBuilder sort(String name)
name
- The name of the field to sort bypublic SearchSourceBuilder sort(SortBuilder sort)
public SearchSourceBuilder trackScores(boolean trackScores)
public SearchSourceBuilder aggregation(AbstractAggregationBuilder aggregation)
public SearchSourceBuilder aggregations(byte[] aggregationsBinary)
public SearchSourceBuilder aggregations(byte[] aggregationsBinary, int aggregationsBinaryOffset, int aggregationsBinaryLength)
public SearchSourceBuilder aggregations(BytesReference aggregationsBinary)
public SearchSourceBuilder aggregations(XContentBuilder aggs)
@Deprecated public SearchSourceBuilder defaultRescoreWindowSize(int defaultRescoreWindowSize)
RescoreBuilder.windowSize(int)
instead.public SearchSourceBuilder aggregations(Map aggregations)
public HighlightBuilder highlighter()
public SearchSourceBuilder highlight(HighlightBuilder highlightBuilder)
public InnerHitsBuilder innerHitsBuilder()
public SuggestBuilder suggest()
public SearchSourceBuilder addRescorer(RescoreBuilder rescoreBuilder)
public SearchSourceBuilder clearRescorers()
public SearchSourceBuilder profile(boolean profile)
public boolean profile()
null
if
unspecified.public SearchSourceBuilder fetchSource(boolean fetch)
public SearchSourceBuilder fetchSource(@Nullable String include, @Nullable 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 SearchSourceBuilder fetchSource(@Nullable String[] includes, @Nullable 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 SearchSourceBuilder fetchSource(@Nullable FetchSourceContext fetchSourceContext)
public SearchSourceBuilder noFields()
public SearchSourceBuilder fields(List<String> fields)
public SearchSourceBuilder fields(String... fields)
public SearchSourceBuilder field(String name)
public SearchSourceBuilder fieldDataField(String name)
public SearchSourceBuilder scriptField(String name, Script script)
name
- The name of the fieldscript
- The scriptpublic SearchSourceBuilder indexBoost(String index, float indexBoost)
index
- The index to apply the boost againstindexBoost
- The boost to apply to the indexpublic SearchSourceBuilder stats(String... statsGroups)
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
IOException
public void innerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
IOException
Copyright © 2009–2017. All rights reserved.