Class Query

java.lang.Object
redis.clients.jedis.search.Query
All Implemented Interfaces:
IParams

public class Query extends Object implements IParams
Query represents query parameters and filters to load results from the engine
  • Field Details

    • _filters

      private final List<Query.Filter> _filters
      The query's filter list. We only support AND operation on all those filters
    • _queryString

      private final String _queryString
      The textual part of the query
    • _paging

      private final Query.Paging _paging
      The sorting parameters
    • _verbatim

      private boolean _verbatim
    • _noContent

      private boolean _noContent
    • _noStopwords

      private boolean _noStopwords
    • _withScores

      private boolean _withScores
    • _withPayloads

      private boolean _withPayloads
    • _language

      private String _language
    • _fields

      private String[] _fields
    • _keys

      private String[] _keys
    • _returnFields

      private String[] _returnFields
    • returnFieldNames

      private FieldName[] returnFieldNames
    • highlightFields

      private String[] highlightFields
    • summarizeFields

      private String[] summarizeFields
    • highlightTags

      private String[] highlightTags
    • summarizeSeparator

      private String summarizeSeparator
    • summarizeNumFragments

      private int summarizeNumFragments
    • summarizeFragmentLen

      private int summarizeFragmentLen
    • _payload

      private byte[] _payload
    • _sortBy

      private String _sortBy
    • _sortAsc

      private boolean _sortAsc
    • wantsHighlight

      private boolean wantsHighlight
    • wantsSummarize

      private boolean wantsSummarize
    • _scorer

      private String _scorer
    • _params

      private Map<String,Object> _params
    • _dialect

      private int _dialect
    • _slop

      private int _slop
    • _timeout

      private long _timeout
    • _inOrder

      private boolean _inOrder
    • _expander

      private String _expander
  • Constructor Details

    • Query

      public Query()
    • Query

      public Query(String queryString)
      Create a new index
      Parameters:
      queryString - the textual part of the query
  • Method Details

    • addParams

      public void addParams(CommandArguments args)
      Specified by:
      addParams in interface IParams
    • limit

      public Query limit(Integer offset, Integer limit)
      Limit the results to a certain offset and limit
      Parameters:
      offset - the first result to show, zero based indexing
      limit - how many results we want to show
      Returns:
      the query itself, for builder-style syntax
    • addFilter

      public Query addFilter(Query.Filter f)
      Add a filter to the query's filter list
      Parameters:
      f - either a numeric or geo filter object
      Returns:
      the query itself
    • setPayload

      @Deprecated public Query setPayload(byte[] payload)
      Deprecated.
      Since RediSearch 2.0.0, PAYLOAD option is deprecated.
      Set the query payload to be evaluated by the scoring function
      Returns:
      the query object itself
    • setVerbatim

      public Query setVerbatim()
      Set the query to verbatim mode, disabling stemming and query expansion
      Returns:
      the query object
    • getNoContent

      public boolean getNoContent()
    • setNoContent

      public Query setNoContent()
      Set the query not to return the contents of documents, and rather just return the ids
      Returns:
      the query itself
    • setNoStopwords

      public Query setNoStopwords()
      Set the query not to filter for stopwords. In general this should not be used
      Returns:
      the query object
    • getWithScores

      public boolean getWithScores()
    • setWithScores

      public Query setWithScores()
      Set the query to return a factored score for each results. This is useful to merge results from multiple queries.
      Returns:
      the query object itself
    • getWithPayloads

      @Deprecated public boolean getWithPayloads()
      Deprecated.
    • setWithPayload

      @Deprecated public Query setWithPayload()
      Deprecated.
      Since RediSearch 2.0.0, WITHPAYLOADS option is deprecated.
      Set the query to return object payloads, if any were given
      Returns:
      the query object itself
    • setLanguage

      public Query setLanguage(String language)
      Set the query language, for stemming purposes

      See http://redisearch.io for documentation on languages and stemming

      Parameters:
      language - a language.
      Returns:
      the query object itself
    • setScorer

      public Query setScorer(String scorer)
      Set the query custom scorer

      See http://redisearch.io for documentation on extending RediSearch

      Parameters:
      scorer - a custom scorer.
      Returns:
      the query object itself
    • limitFields

      public Query limitFields(String... fields)
      Limit the query to results that are limited to a specific set of fields
      Parameters:
      fields - a list of TEXT fields in the schemas
      Returns:
      the query object itself
    • limitKeys

      public Query limitKeys(String... keys)
      Limit the query to results that are limited to a specific set of keys
      Parameters:
      keys - a list of TEXT fields in the schemas
      Returns:
      the query object itself
    • returnFields

      public Query returnFields(String... fields)
      Result's projection - the fields to return by the query
      Parameters:
      fields - a list of TEXT fields in the schemas
      Returns:
      the query object itself
    • returnFields

      public Query returnFields(FieldName... fields)
      Result's projection - the fields to return by the query
      Parameters:
      fields - a list of TEXT fields in the schemas
      Returns:
      the query object itself
    • highlightFields

      public Query highlightFields(Query.HighlightTags tags, String... fields)
    • highlightFields

      public Query highlightFields(String... fields)
    • summarizeFields

      public Query summarizeFields(int contextLen, int fragmentCount, String separator, String... fields)
    • summarizeFields

      public Query summarizeFields(String... fields)
    • setSortBy

      public Query setSortBy(String field, boolean ascending)
      Set the query to be sorted by a Sortable field defined in the schema
      Parameters:
      field - the sorting field's name
      ascending - if set to true, the sorting order is ascending, else descending
      Returns:
      the query object itself
    • addParam

      public Query addParam(String name, Object value)
      Parameters can be referenced in the query string by a $ , followed by the parameter name, e.g., $user , and each such reference in the search query to a parameter name is substituted by the corresponding parameter value.
      Parameters:
      name -
      value - can be String, long or float
      Returns:
      the query object itself
    • dialect

      public Query dialect(int dialect)
      Set the dialect version to execute the query accordingly
      Parameters:
      dialect - integer
      Returns:
      the query object itself
    • slop

      public Query slop(int slop)
      Set the slop to execute the query accordingly
      Parameters:
      slop - integer
      Returns:
      the query object itself
    • timeout

      public Query timeout(long timeout)
      Set the timeout to execute the query accordingly
      Parameters:
      timeout - long
      Returns:
      the query object itself
    • setInOrder

      public Query setInOrder()
      Set the query terms appear in the same order in the document as in the query, regardless of the offsets between them
      Returns:
      the query object
    • setExpander

      public Query setExpander(String field)
      Set the query to use a custom query expander instead of the stemmer
      Parameters:
      field - the expander field's name
      Returns:
      the query object itself