Class SearchRequest
- java.lang.Object
-
- co.elasticsearch.enterprisesearch.client.model.request.search.SearchRequest
-
public class SearchRequest extends Object
Represents a request to the search api
-
-
Constructor Summary
Constructors Constructor Description SearchRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)AnalyticsgetAnalytics()Submit tags with the analytics parameter.List<Boost>getBoosts()Get the boostsList<Facet>getFacets()Get the facetsFiltergetFilters()Apply conditions to field values to filter results.GroupgetGroup()Grouped results based on shared fields.PagegetPage()Object to delimit the pagination parameters.IntegergetPrecision()Use the precision parameter of the search API to tune precision and recall for a query.StringgetQuery()String or number to match.
The value "" (empty string) matches all documents.BooleangetRecordAnalytics()If true, generates an analytics query event for the search request.List<ResultField>getResultFields()Get the result fieldsList<SearchField>getSearchFields()Get the search fieldsList<Sort>getSort()Sort your results in an order other than document score.inthashCode()SearchRequestsetAnalytics(Analytics analytics)Submit tags with the analytics parameter.SearchRequestsetFilters(Filter filters)Apply conditions to field values to filter results.SearchRequestsetGroup(Group group)Grouped results based on shared fields.SearchRequestsetPage(Page page)Object to delimit the pagination parameters.SearchRequestsetPrecision(Integer precision)Use the precision parameter of the search API to tune precision and recall for a query.SearchRequestsetQuery(String query)String or number to match.
The value "" (empty string) matches all documents.SearchRequestsetRecordAnalytics(Boolean recordAnalytics)If true, generates an analytics query event for the search request.SearchRequestsetSort(List<Sort> sort)Sort your results in an order other than document score.StringtoString()SearchRequestwithBoosts(Boost... boosts)Provide a field to boost, then increase document relevance based on values.SearchRequestwithFacets(Facet... facets)Provides the counts of each value or range for a field.SearchRequestwithResultFields(ResultField... fields)Change the fields which appear in search results and how their values are rendered.SearchRequestwithSearchFields(SearchField... fields)Restricts a query to search only specific fields.SearchRequestwithSorts(Sort... sorts)Sort your results in an order other than document score.SearchRequestwithTags(String... tags)Tags can be used to enrich each query with unique information.
-
-
-
Method Detail
-
withSorts
public SearchRequest withSorts(Sort... sorts)
Sort your results in an order other than document score. Using sort will override the default relevance scoring method. A special sorting field name is available, _score, to order by relevance.- Parameters:
sorts- The fields to sort the results- Returns:
- This request
-
withTags
public SearchRequest withTags(String... tags)
Tags can be used to enrich each query with unique information.- Parameters:
tags- The analytics tags for this query- Returns:
- this request
-
withFacets
public SearchRequest withFacets(Facet... facets)
Provides the counts of each value or range for a field. When faceting on an array field, each unique value will be included in the response. Each value is only counted once.- Parameters:
facets- the facets- Returns:
- this request
-
withBoosts
public SearchRequest withBoosts(Boost... boosts)
Provide a field to boost, then increase document relevance based on values. Boosts affect the score of the entire document.- Parameters:
boosts- The boosts to apply- Returns:
- this request
-
withSearchFields
public SearchRequest withSearchFields(SearchField... fields)
Restricts a query to search only specific fields. Restricting fields will result in faster queries, especially for schemas with many text fields. Only available within text fields.- Parameters:
fields- The fields- Returns:
- this request
-
withResultFields
public SearchRequest withResultFields(ResultField... fields)
Change the fields which appear in search results and how their values are rendered.- Parameters:
fields- The fields to include in the result- Returns:
- The fields to include in the result
-
getSearchFields
public List<SearchField> getSearchFields()
Get the search fields- Returns:
- the search fields
-
getResultFields
public List<ResultField> getResultFields()
Get the result fields- Returns:
- the result fields
-
getQuery
public String getQuery()
String or number to match.
The value "" (empty string) matches all documents. (Note that API limits for documents returned applies.)
The following Lucene query syntax is supported:- double quoted strings
+and-AND,OR,NOT
- Returns:
- query to match
-
getPage
public Page getPage()
Object to delimit the pagination parameters.- Returns:
- the page
-
getSort
public List<Sort> getSort()
Sort your results in an order other than document score. Using sort will override the default relevance scoring method. A special sorting field name is available, _score, to order by relevance.- Returns:
- the sorts
-
getGroup
public Group getGroup()
Grouped results based on shared fields. The most relevant document will have a _group key. The key includes all other documents that share an identical value within the grouped field. Documents in the _group key will not appear anywhere else in the search response.- Returns:
- the groups
-
getFilters
public Filter getFilters()
Apply conditions to field values to filter results.- Returns:
- the filters
-
getPrecision
public Integer getPrecision()
Use the precision parameter of the search API to tune precision and recall for a query. Learn more in Precision tuning (beta).
The range of values represents a sliding scale that manages the inherent tradeoff between precision and recall.- Returns:
- the precision
-
getAnalytics
public Analytics getAnalytics()
Submit tags with the analytics parameter. Tags can be used to enrich each query with unique information. Once added, a tag cannot be removed.- Returns:
- the analytics
-
getRecordAnalytics
public Boolean getRecordAnalytics()
If true, generates an analytics query event for the search request. Defaults to true.- Returns:
- true if analytics are recorded
-
setQuery
public SearchRequest setQuery(String query)
String or number to match.
The value "" (empty string) matches all documents. (Note that API limits for documents returned applies.)
The following Lucene query syntax is supported:- double quoted strings
+and-AND,OR,NOT
- Parameters:
query- String or number to match- Returns:
this.
-
setPage
public SearchRequest setPage(Page page)
Object to delimit the pagination parameters.- Parameters:
page- The page parameters- Returns:
this.
-
setSort
public SearchRequest setSort(List<Sort> sort)
Sort your results in an order other than document score. Using sort will override the default relevance scoring method. A special sorting field name is available, _score, to order by relevance.- Parameters:
sort- The fields to sort the results- Returns:
this.
-
setGroup
public SearchRequest setGroup(Group group)
Grouped results based on shared fields. The most relevant document will have a _group key. The key includes all other documents that share an identical value within the grouped field. Documents in the _group key will not appear anywhere else in the search response.- Parameters:
group- The group parameters- Returns:
this.
-
setFilters
public SearchRequest setFilters(Filter filters)
Apply conditions to field values to filter results.- Parameters:
filters- The filters to apply to the search- Returns:
this.
-
setPrecision
public SearchRequest setPrecision(Integer precision)
Use the precision parameter of the search API to tune precision and recall for a query. Learn more in Precision tuning (beta).
The range of values represents a sliding scale that manages the inherent tradeoff between precision and recall.- Parameters:
precision- A value between 1 and 11, inclusive. Lower values favor recall, while higher values favor precision.- Returns:
this.
-
setAnalytics
public SearchRequest setAnalytics(Analytics analytics)
Submit tags with the analytics parameter. Tags can be used to enrich each query with unique information. Once added, a tag cannot be removed.- Parameters:
analytics- The analytics tags for this query- Returns:
this.
-
setRecordAnalytics
public SearchRequest setRecordAnalytics(Boolean recordAnalytics)
If true, generates an analytics query event for the search request. Defaults to true.- Parameters:
recordAnalytics- Whether analytics should be recorded- Returns:
this.
-
canEqual
protected boolean canEqual(Object other)
-
-