public class NativeSearchQuery extends Object
https://www.elastic.co/guide/en/elasticsearch/reference/7.9/filter-search-results.html#post-filter, if a
filter is needed that filters before aggregations are build, it must be included in the query constructor parameter.| Modifier and Type | Field and Description |
|---|---|
protected List<String> |
fields |
protected HighlightQuery |
highlightQuery |
protected Collection<String> |
ids |
protected org.elasticsearch.action.support.IndicesOptions |
indicesOptions |
protected Integer |
maxResults |
protected float |
minScore |
protected Pageable |
pageable |
protected String |
preference |
protected String |
route |
protected org.elasticsearch.action.search.SearchType |
searchType |
protected Sort |
sort |
protected SourceFilter |
sourceFilter |
protected boolean |
trackScores |
DEFAULT_PAGE, DEFAULT_PAGE_SIZE| Constructor and Description |
|---|
NativeSearchQuery(org.elasticsearch.index.query.QueryBuilder query) |
NativeSearchQuery(org.elasticsearch.index.query.QueryBuilder query,
org.elasticsearch.index.query.QueryBuilder filter) |
NativeSearchQuery(org.elasticsearch.index.query.QueryBuilder query,
org.elasticsearch.index.query.QueryBuilder filter,
List<org.elasticsearch.search.sort.SortBuilder<?>> sorts) |
NativeSearchQuery(org.elasticsearch.index.query.QueryBuilder query,
org.elasticsearch.index.query.QueryBuilder filter,
List<org.elasticsearch.search.sort.SortBuilder<?>> sorts,
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field[] highlightFields) |
NativeSearchQuery(org.elasticsearch.index.query.QueryBuilder query,
org.elasticsearch.index.query.QueryBuilder filter,
List<org.elasticsearch.search.sort.SortBuilder<?>> sorts,
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder highlightBuilder,
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field[] highlightFields) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAggregation(org.elasticsearch.search.aggregations.AbstractAggregationBuilder<?> aggregationBuilder) |
void |
addFields(String... fields)
Add fields to be added as part of search request
|
void |
addScriptField(ScriptField... scriptField) |
<T extends Query> |
addSort(Sort sort)
Add
Sort to query |
void |
addSourceFilter(SourceFilter sourceFilter)
Add source filter to be added as part of search request
|
List<org.elasticsearch.search.aggregations.AbstractAggregationBuilder<?>> |
getAggregations() |
org.elasticsearch.search.collapse.CollapseBuilder |
getCollapseBuilder() |
List<org.elasticsearch.search.sort.SortBuilder<?>> |
getElasticsearchSorts() |
List<String> |
getFields()
Get fields to be returned as part of search request
|
org.elasticsearch.index.query.QueryBuilder |
getFilter() |
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder |
getHighlightBuilder() |
org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field[] |
getHighlightFields() |
Optional<HighlightQuery> |
getHighlightQuery() |
Collection<String> |
getIds()
Get Ids
|
List<IndexBoost> |
getIndicesBoost() |
org.elasticsearch.action.support.IndicesOptions |
getIndicesOptions()
Get indices options
|
Integer |
getMaxResults()
return the max of results.
|
float |
getMinScore()
Get minimum score
|
Pageable |
getPageable()
Get page settings if defined
|
String |
getPreference()
Get preference
|
org.elasticsearch.index.query.QueryBuilder |
getQuery() |
String |
getRoute()
Get route
|
List<ScriptField> |
getScriptFields() |
Duration |
getScrollTime()
For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete
queries.
|
org.elasticsearch.action.search.SearchType |
getSearchType()
Type of search
|
Sort |
getSort() |
SourceFilter |
getSourceFilter()
Get SourceFilter to be returned to get include and exclude source fields as part of search request.
|
boolean |
getTrackScores()
Get if scores will be computed and tracked, regardless of whether sorting on a field.
|
Boolean |
getTrackTotalHits()
Sets the flag whether to set the Track_total_hits parameter on queries Elasticseacrh
documentation>
|
Integer |
getTrackTotalHitsUpTo()
Gets the maximum value up to which total hits are tracked.
|
boolean |
isLimiting() |
void |
setAggregations(List<org.elasticsearch.search.aggregations.AbstractAggregationBuilder<?>> aggregations) |
void |
setCollapseBuilder(org.elasticsearch.search.collapse.CollapseBuilder collapseBuilder) |
void |
setHighlightQuery(HighlightQuery highlightQuery)
Sets the
HighlightQuery. |
void |
setIds(Collection<String> ids) |
void |
setIndicesBoost(List<IndexBoost> indicesBoost) |
void |
setIndicesOptions(org.elasticsearch.action.support.IndicesOptions indicesOptions) |
void |
setMaxResults(Integer maxResults) |
void |
setMinScore(float minScore) |
<T extends Query> |
setPageable(Pageable pageable)
restrict result to entries on given page.
|
void |
setPreference(String preference)
Add preference filter to be added as part of search request
|
void |
setRoute(String route) |
void |
setScriptFields(List<ScriptField> scriptFields) |
void |
setScrollTime(Duration scrollTime)
For queries that are used in delete request, these are internally handled by Elasticsearch as scroll/bulk delete
queries.
|
void |
setSearchType(org.elasticsearch.action.search.SearchType searchType) |
void |
setTrackScores(boolean trackScores)
Configures whether to track scores.
|
void |
setTrackTotalHits(Boolean trackTotalHits)
Sets the flag whether to set the Track_total_hits parameter on queries Elasticseacrh
documentation>
|
void |
setTrackTotalHitsUpTo(Integer trackTotalHitsUpTo)
Sets the maximum value up to which total hits are tracked.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfindAll, hasScrollTimeprotected Pageable pageable
@Nullable protected SourceFilter sourceFilter
protected float minScore
@Nullable protected Collection<String> ids
protected org.elasticsearch.action.search.SearchType searchType
@Nullable protected org.elasticsearch.action.support.IndicesOptions indicesOptions
protected boolean trackScores
@Nullable protected HighlightQuery highlightQuery
public NativeSearchQuery(@Nullable org.elasticsearch.index.query.QueryBuilder query)
public NativeSearchQuery(@Nullable org.elasticsearch.index.query.QueryBuilder query, @Nullable org.elasticsearch.index.query.QueryBuilder filter)
public NativeSearchQuery(@Nullable org.elasticsearch.index.query.QueryBuilder query, @Nullable org.elasticsearch.index.query.QueryBuilder filter, @Nullable List<org.elasticsearch.search.sort.SortBuilder<?>> sorts)
public NativeSearchQuery(@Nullable org.elasticsearch.index.query.QueryBuilder query, @Nullable org.elasticsearch.index.query.QueryBuilder filter, @Nullable List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, @Nullable org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field[] highlightFields)
public NativeSearchQuery(@Nullable org.elasticsearch.index.query.QueryBuilder query, @Nullable org.elasticsearch.index.query.QueryBuilder filter, @Nullable List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, @Nullable org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder highlightBuilder, @Nullable org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field[] highlightFields)
@Nullable public org.elasticsearch.index.query.QueryBuilder getQuery()
@Nullable public org.elasticsearch.index.query.QueryBuilder getFilter()
@Nullable public List<org.elasticsearch.search.sort.SortBuilder<?>> getElasticsearchSorts()
@Nullable public org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder getHighlightBuilder()
@Nullable public org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field[] getHighlightFields()
public List<ScriptField> getScriptFields()
public void setScriptFields(List<ScriptField> scriptFields)
public void addScriptField(ScriptField... scriptField)
@Nullable public org.elasticsearch.search.collapse.CollapseBuilder getCollapseBuilder()
public void setCollapseBuilder(org.elasticsearch.search.collapse.CollapseBuilder collapseBuilder)
@Nullable public List<org.elasticsearch.search.aggregations.AbstractAggregationBuilder<?>> getAggregations()
public void addAggregation(org.elasticsearch.search.aggregations.AbstractAggregationBuilder<?> aggregationBuilder)
public void setAggregations(List<org.elasticsearch.search.aggregations.AbstractAggregationBuilder<?>> aggregations)
@Nullable public List<IndexBoost> getIndicesBoost()
public void setIndicesBoost(List<IndexBoost> indicesBoost)
public Pageable getPageable()
QuerygetPageable in interface Querypublic final <T extends Query> T setPageable(Pageable pageable)
QuerysetPageable in interface Querypublic void addFields(String... fields)
Querypublic List<String> getFields()
Querypublic void addSourceFilter(SourceFilter sourceFilter)
QueryaddSourceFilter in interface Query@Nullable public SourceFilter getSourceFilter()
QuerygetSourceFilter in interface Querypublic final <T extends Query> T addSort(Sort sort)
QuerySort to querypublic float getMinScore()
QuerygetMinScore in interface Querypublic void setMinScore(float minScore)
@Nullable public Collection<String> getIds()
Querypublic void setIds(Collection<String> ids)
public void setRoute(String route)
public void setSearchType(org.elasticsearch.action.search.SearchType searchType)
public org.elasticsearch.action.search.SearchType getSearchType()
QuerygetSearchType in interface Query@Nullable public org.elasticsearch.action.support.IndicesOptions getIndicesOptions()
QuerygetIndicesOptions in interface Querypublic void setIndicesOptions(org.elasticsearch.action.support.IndicesOptions indicesOptions)
public boolean getTrackScores()
QuerygetTrackScores in interface Querypublic void setTrackScores(boolean trackScores)
trackScores - @Nullable public String getPreference()
QuerygetPreference in interface Querypublic void setPreference(String preference)
QuerysetPreference in interface Querypublic boolean isLimiting()
isLimiting in interface Query@Nullable public Integer getMaxResults()
QueryQuery.isLimiting() returns true.getMaxResults in interface Querypublic void setMaxResults(Integer maxResults)
public void setHighlightQuery(HighlightQuery highlightQuery)
QueryHighlightQuery.setHighlightQuery in interface QueryhighlightQuery - the query to setpublic Optional<HighlightQuery> getHighlightQuery()
getHighlightQuery in interface QueryHighlightQuery.public void setTrackTotalHits(@Nullable Boolean trackTotalHits)
QuerysetTrackTotalHits in interface QuerytrackTotalHits - the value to set.@Nullable public Boolean getTrackTotalHits()
QuerygetTrackTotalHits in interface Querypublic void setTrackTotalHitsUpTo(@Nullable Integer trackTotalHitsUpTo)
QuerysetTrackTotalHitsUpTo in interface QuerytrackTotalHitsUpTo - max limit for trackTotalHits@Nullable public Integer getTrackTotalHitsUpTo()
QuerygetTrackTotalHitsUpTo in interface Query@Nullable public Duration getScrollTime()
QueryQuery.hasScrollTime() returns true.getScrollTime in interface Querypublic void setScrollTime(@Nullable Duration scrollTime)
QuerysetScrollTime in interface QueryscrollTime - the scrolltime settingsCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.