Class SearchRequest


  • public class SearchRequest
    extends Object
    Represents a request to the search api
    • Constructor Detail

      • SearchRequest

        public SearchRequest()
    • 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
      • getBoosts

        public List<Boost> getBoosts()
        Get the boosts
        Returns:
        the boosts
      • 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
      • getFacets

        public List<Facet> getFacets()
        Get the facets
        Returns:
        The facets
      • 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)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object