public class SearchSourceBuilder extends Object implements ToXContent
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 facets)
Sets a raw (xcontent / json) addAggregation.
|
BytesReference |
buildAsBytes() |
BytesReference |
buildAsBytes(XContentType contentType) |
SearchSourceBuilder |
clearRescorers() |
SearchSourceBuilder |
defaultRescoreWindowSize(int defaultRescoreWindowSize)
Set the rescore window size for rescores that don't specify their window.
|
SearchSourceBuilder |
explain(Boolean explain)
Should each
SearchHit be returned with an
explanation of the hit (ranking). |
SearchSourceBuilder |
facet(FacetBuilder facet)
Add a facet to perform as part of the search.
|
SearchSourceBuilder |
facets(byte[] facetsBinary)
Sets a raw (xcontent / json) facets.
|
SearchSourceBuilder |
facets(byte[] facetsBinary,
int facetBinaryOffset,
int facetBinaryLength)
Sets a raw (xcontent / json) facets.
|
SearchSourceBuilder |
facets(BytesReference facetsBinary)
Sets a raw (xcontent / json) facets.
|
SearchSourceBuilder |
facets(Map facets)
Sets a raw (xcontent / json) facets.
|
SearchSourceBuilder |
facets(XContentBuilder facets)
Sets a raw (xcontent / json) facets.
|
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 |
partialField(String name,
String[] includes,
String[] excludes)
Deprecated.
since 1.0.0
use
fetchSource(String[], String[]) instead |
SearchSourceBuilder |
partialField(String name,
String include,
String exclude)
Deprecated.
since 1.0.0
use
fetchSource(String, String) instead |
SearchSourceBuilder |
postFilter(byte[] postFilter)
Sets a filter on the query executed that only applies to the search query
(and not facets 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 facets for example).
|
SearchSourceBuilder |
postFilter(BytesReference postFilterBinary)
Sets a filter on the query executed that only applies to the search query
(and not facets for example).
|
SearchSourceBuilder |
postFilter(FilterBuilder postFilter)
Sets a filter that will be executed after the query has been executed and only has affect on the search hits
(not aggregations or facets).
|
SearchSourceBuilder |
postFilter(Map postFilter)
Constructs a new search source builder with a query from a map.
|
SearchSourceBuilder |
postFilter(String postFilterString)
Sets a filter on the query executed that only applies to the search query
(and not facets for example).
|
SearchSourceBuilder |
postFilter(XContentBuilder postFilter)
Constructs a new search source builder with a query from a builder.
|
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(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,
String script)
Adds a script field under the given name with the provided script.
|
SearchSourceBuilder |
scriptField(String name,
String script,
Map<String,Object> params)
Adds a script field.
|
SearchSourceBuilder |
scriptField(String name,
String lang,
String script,
Map<String,Object> params)
Adds a script field.
|
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.
|
String |
toString() |
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. |
public SearchSourceBuilder()
public static SearchSourceBuilder searchSource()
public static HighlightBuilder highlight()
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(FilterBuilder 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 facet(FacetBuilder facet)
public SearchSourceBuilder facets(byte[] facetsBinary)
public SearchSourceBuilder facets(byte[] facetsBinary, int facetBinaryOffset, int facetBinaryLength)
public SearchSourceBuilder facets(BytesReference facetsBinary)
public SearchSourceBuilder facets(XContentBuilder facets)
public SearchSourceBuilder facets(Map facets)
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 facets)
public SearchSourceBuilder defaultRescoreWindowSize(int defaultRescoreWindowSize)
defaultRescoreWindowSize
- 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 fetchSource(boolean fetch)
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, String script)
name
- The name of the fieldscript
- The scriptpublic SearchSourceBuilder scriptField(String name, String script, Map<String,Object> params)
name
- The name of the fieldscript
- The script to executeparams
- The script parameterspublic SearchSourceBuilder scriptField(String name, String lang, String script, Map<String,Object> params)
name
- The name of the fieldlang
- The language of the scriptscript
- The script to executeparams
- The script parameters (can be null)@Deprecated public SearchSourceBuilder partialField(String name, @Nullable String include, @Nullable String exclude)
fetchSource(String, String)
insteadname
- The name of the fieldinclude
- An optional include (optionally wildcarded) pattern from _sourceexclude
- An optional exclude (optionally wildcarded) pattern from _source@Deprecated public SearchSourceBuilder partialField(String name, @Nullable String[] includes, @Nullable String[] excludes)
fetchSource(String[], String[])
insteadname
- The name of the fieldincludes
- An optional list of includes (optionally wildcarded) patterns from _sourceexcludes
- An optional list of excludes (optionally wildcarded) patterns from _sourcepublic 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 BytesReference buildAsBytes() throws SearchSourceBuilderException
SearchSourceBuilderException
public BytesReference buildAsBytes(XContentType contentType) throws SearchSourceBuilderException
SearchSourceBuilderException
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
toXContent
in interface ToXContent
IOException
public void innerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
IOException
Copyright © 2009–2015. All rights reserved.