Package org.redisson

Class RedissonSearch

java.lang.Object
org.redisson.RedissonSearch
All Implemented Interfaces:
RSearch, RSearchAsync

public class RedissonSearch extends Object implements RSearch
Author:
Nikita Koksharov
  • Constructor Details

  • Method Details

    • createIndex

      public void createIndex(String indexName, IndexOptions options, FieldIndex... fields)
      Description copied from interface: RSearch
      Creates an index.

      Code example:

                   search.create("idx", IndexOptions.defaults()
                                           .on(IndexType.HASH)
                                           .prefix(Arrays.asList("doc:")),
                                           FieldIndex.text("t1"),
                                           FieldIndex.tag("t2").withSuffixTrie());
       
      Specified by:
      createIndex in interface RSearch
      Parameters:
      indexName - index name
      options - index options
      fields - fields
    • createIndexAsync

      public RFuture<Void> createIndexAsync(String indexName, IndexOptions options, FieldIndex... fields)
      Description copied from interface: RSearchAsync
      Creates an index.

      Code example:

                   search.create("idx", IndexOptions.defaults()
                                           .on(IndexType.HASH)
                                           .prefix(Arrays.asList("doc:")),
                                           FieldIndex.text("t1"),
                                           FieldIndex.tag("t2").withSuffixTrie());
       
      Specified by:
      createIndexAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      options - index options
      fields - fields
    • search

      public SearchResult search(String indexName, String query, QueryOptions options)
      Description copied from interface: RSearch
      Executes search over defined index using defined query.

      Code example:

       SearchResult r = s.search("idx", "*", QueryOptions.defaults()
                                                         .returnAttributes(new ReturnAttribute("t1"), new ReturnAttribute("t2")));
       
      Specified by:
      search in interface RSearch
      Parameters:
      indexName - index name
      query - query value
      options - query options
      Returns:
      search result
    • searchAsync

      public RFuture<SearchResult> searchAsync(String indexName, String query, QueryOptions options)
      Description copied from interface: RSearchAsync
      Executes search over defined index using defined query.

      Code example:

       SearchResult r = s.search("idx", "*", QueryOptions.defaults()
                                                         .returnAttributes(new ReturnAttribute("t1"), new ReturnAttribute("t2")));
       
      Specified by:
      searchAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      query - query value
      options - query options
      Returns:
      search result
    • aggregate

      public AggregationResult aggregate(String indexName, String query, AggregationOptions options)
      Description copied from interface: RSearch
      Executes aggregation over defined index using defined query.

      Code example:

       AggregationResult r = s.aggregate("idx", "*", AggregationOptions.defaults()
                                                                       .load("t1", "t2"));
       
      Specified by:
      aggregate in interface RSearch
      Parameters:
      indexName - index name
      query - query value
      options - aggregation options
      Returns:
      aggregation result
    • aggregateAsync

      public RFuture<AggregationResult> aggregateAsync(String indexName, String query, AggregationOptions options)
      Description copied from interface: RSearchAsync
      Executes aggregation over defined index using defined query.

      Code example:

       AggregationResult r = s.aggregate("idx", "*", AggregationOptions.defaults()
                                                                       .load("t1", "t2"));
       
      Specified by:
      aggregateAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      query - query value
      options - aggregation options
      Returns:
      aggregation result
    • addAlias

      public void addAlias(String alias, String indexName)
      Description copied from interface: RSearch
      Adds alias to defined index name
      Specified by:
      addAlias in interface RSearch
      Parameters:
      alias - alias value
      indexName - index name
    • addAliasAsync

      public RFuture<Void> addAliasAsync(String alias, String indexName)
      Description copied from interface: RSearchAsync
      Adds alias to defined index name
      Specified by:
      addAliasAsync in interface RSearchAsync
      Parameters:
      alias - alias value
      indexName - index name
    • delAlias

      public void delAlias(String alias)
      Description copied from interface: RSearch
      Deletes index alias
      Specified by:
      delAlias in interface RSearch
      Parameters:
      alias - alias value
    • delAliasAsync

      public RFuture<Void> delAliasAsync(String alias)
      Description copied from interface: RSearchAsync
      Deletes index alias
      Specified by:
      delAliasAsync in interface RSearchAsync
      Parameters:
      alias - alias value
    • updateAlias

      public void updateAlias(String alias, String indexName)
      Description copied from interface: RSearch
      Adds alias to defined index name. Re-assigns the alias if it was used before with a different index.
      Specified by:
      updateAlias in interface RSearch
      Parameters:
      alias - alias value
      indexName - index name
    • updateAliasAsync

      public RFuture<Void> updateAliasAsync(String alias, String indexName)
      Description copied from interface: RSearchAsync
      Adds alias to defined index name. Re-assigns the alias if it was used before with a different index.
      Specified by:
      updateAliasAsync in interface RSearchAsync
      Parameters:
      alias - alias value
      indexName - index name
    • alter

      public void alter(String indexName, boolean skipInitialScan, FieldIndex... fields)
      Description copied from interface: RSearch
      Adds a new attribute to the index
      Specified by:
      alter in interface RSearch
      Parameters:
      indexName - index name
      skipInitialScan - doesn't scan the index if true
      fields - field indexes
    • alterAsync

      public RFuture<Void> alterAsync(String indexName, boolean skipInitialScan, FieldIndex... fields)
      Description copied from interface: RSearchAsync
      Adds a new attribute to the index
      Specified by:
      alterAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      skipInitialScan - doesn't scan the index if true
      fields - field indexes
    • getConfig

      public Map<String,String> getConfig(String parameter)
      Description copied from interface: RSearch
      Returns configuration map by defined parameter name
      Specified by:
      getConfig in interface RSearch
      Parameters:
      parameter - parameter name
      Returns:
      configuration map
    • getConfigAsync

      public RFuture<Map<String,String>> getConfigAsync(String parameter)
      Description copied from interface: RSearchAsync
      Returns configuration map by defined parameter name
      Specified by:
      getConfigAsync in interface RSearchAsync
      Parameters:
      parameter - parameter name
      Returns:
      configuration map
    • setConfig

      public void setConfig(String parameter, String value)
      Description copied from interface: RSearch
      Sets configuration value by the parameter name
      Specified by:
      setConfig in interface RSearch
      Parameters:
      parameter - parameter name
      value - parameter value
    • setConfigAsync

      public RFuture<Void> setConfigAsync(String parameter, String value)
      Description copied from interface: RSearchAsync
      Sets configuration value by the parameter name
      Specified by:
      setConfigAsync in interface RSearchAsync
      Parameters:
      parameter - parameter name
      value - parameter value
    • delCursor

      public void delCursor(String indexName, long cursorId)
      Description copied from interface: RSearch
      Deletes cursor by index name and id
      Specified by:
      delCursor in interface RSearch
      Parameters:
      indexName - index name
      cursorId - cursor id
    • delCursorAsync

      public RFuture<Void> delCursorAsync(String indexName, long cursorId)
      Description copied from interface: RSearchAsync
      Deletes cursor by index name and id
      Specified by:
      delCursorAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      cursorId - cursor id
    • readCursor

      public AggregationResult readCursor(String indexName, long cursorId)
      Description copied from interface: RSearch
      Returns next results by index name and cursor id
      Specified by:
      readCursor in interface RSearch
      Parameters:
      indexName - index name
      cursorId - cursor id
      Returns:
      aggregation result
    • readCursorAsync

      public RFuture<AggregationResult> readCursorAsync(String indexName, long cursorId)
      Description copied from interface: RSearchAsync
      Returns next results by index name and cursor id
      Specified by:
      readCursorAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      cursorId - cursor id
      Returns:
      aggregation result
    • readCursor

      public AggregationResult readCursor(String indexName, long cursorId, int count)
      Description copied from interface: RSearch
      Returns next results by index name, cursor id and results size
      Specified by:
      readCursor in interface RSearch
      Parameters:
      indexName - index name
      cursorId - cursor id
      count - results size
      Returns:
      aggregation result
    • readCursorAsync

      public RFuture<AggregationResult> readCursorAsync(String indexName, long cursorId, int count)
      Description copied from interface: RSearchAsync
      Returns next results by index name, cursor id and results size
      Specified by:
      readCursorAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      cursorId - cursor id
      count - results size
      Returns:
      aggregation result
    • addDict

      public long addDict(String dictionary, String... terms)
      Description copied from interface: RSearch
      Adds defined terms to the dictionary
      Specified by:
      addDict in interface RSearch
      Parameters:
      dictionary - dictionary name
      terms - terms
      Returns:
      number of new terms
    • addDictAsync

      public RFuture<Long> addDictAsync(String dictionary, String... terms)
      Description copied from interface: RSearchAsync
      Adds defined terms to the dictionary
      Specified by:
      addDictAsync in interface RSearchAsync
      Parameters:
      dictionary - dictionary name
      terms - terms
      Returns:
      number of new terms
    • delDict

      public long delDict(String dictionary, String... terms)
      Description copied from interface: RSearch
      Deletes defined terms from the dictionary
      Specified by:
      delDict in interface RSearch
      Parameters:
      dictionary - dictionary name
      terms - terms
      Returns:
      number of deleted terms
    • delDictAsync

      public RFuture<Long> delDictAsync(String dictionary, String... terms)
      Description copied from interface: RSearchAsync
      Deletes defined terms from the dictionary
      Specified by:
      delDictAsync in interface RSearchAsync
      Parameters:
      dictionary - dictionary name
      terms - terms
      Returns:
      number of deleted terms
    • dumpDict

      public List<String> dumpDict(String dictionary)
      Description copied from interface: RSearch
      Returns terms stored in the dictionary
      Specified by:
      dumpDict in interface RSearch
      Parameters:
      dictionary - dictionary name
      Returns:
      terms
    • dumpDictAsync

      public RFuture<List<String>> dumpDictAsync(String dictionary)
      Description copied from interface: RSearchAsync
      Returns terms stored in the dictionary
      Specified by:
      dumpDictAsync in interface RSearchAsync
      Parameters:
      dictionary - dictionary name
      Returns:
      terms
    • dropIndex

      public void dropIndex(String indexName)
      Description copied from interface: RSearch
      Deletes index by name
      Specified by:
      dropIndex in interface RSearch
      Parameters:
      indexName - index name
    • dropIndexAsync

      public RFuture<Void> dropIndexAsync(String indexName)
      Description copied from interface: RSearchAsync
      Deletes index by name and associated documents. Associated documents are deleted asynchronously. Method RSearchAsync.infoAsync(String) can be used to check for process completion.
      Specified by:
      dropIndexAsync in interface RSearchAsync
      Parameters:
      indexName - index name
    • dropIndexAndDocuments

      public void dropIndexAndDocuments(String indexName)
      Description copied from interface: RSearch
      Deletes index by name and associated documents. Associated documents are deleted asynchronously. Method RSearch.info(String) can be used to check for process completion.
      Specified by:
      dropIndexAndDocuments in interface RSearch
      Parameters:
      indexName - index name
    • dropIndexAndDocumentsAsync

      public RFuture<Void> dropIndexAndDocumentsAsync(String indexName)
      Description copied from interface: RSearchAsync
      Deletes index by name and associated documents
      Specified by:
      dropIndexAndDocumentsAsync in interface RSearchAsync
      Parameters:
      indexName - index name
    • info

      public IndexInfo info(String indexName)
      Description copied from interface: RSearch
      Returns index info by name
      Specified by:
      info in interface RSearch
      Parameters:
      indexName - index name
      Returns:
      index info
    • infoAsync

      public RFuture<IndexInfo> infoAsync(String indexName)
      Description copied from interface: RSearchAsync
      Returns index info by name
      Specified by:
      infoAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      Returns:
      index info
    • spellcheck

      public Map<String,Map<String,Double>> spellcheck(String indexName, String query, SpellcheckOptions options)
      Description copied from interface: RSearch
      Executes spell checking by defined index name and query. Returns a map of misspelled terms and their score.
       Mapinvalid input: '<'String, Mapinvalid input: '<'String, Double>> res = s.spellcheck("idx", "Hocke sti", SpellcheckOptions.defaults()
                                                                                                .includedTerms("name"));
       
      Specified by:
      spellcheck in interface RSearch
      Parameters:
      indexName - index name
      query - query
      options - spell checking options
      Returns:
      map of misspelled terms and their score
    • spellcheckAsync

      public RFuture<Map<String,Map<String,Double>>> spellcheckAsync(String indexName, String query, SpellcheckOptions options)
      Description copied from interface: RSearchAsync
      Executes spell checking by defined index name and query. Returns a map of misspelled terms and their score.
       Mapinvalid input: '<'String, Mapinvalid input: '<'String, Double>> res = s.spellcheck("idx", "Hocke sti", SpellcheckOptions.defaults()
                                                                                                .includedTerms("name"));
       
      Specified by:
      spellcheckAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      query - query
      options - spell checking options
      Returns:
      map of misspelled terms and their score
    • dumpSynonyms

      public Map<String,List<String>> dumpSynonyms(String indexName)
      Description copied from interface: RSearch
      Returns synonyms mapped by word by defined index name
      Specified by:
      dumpSynonyms in interface RSearch
      Parameters:
      indexName - index name
      Returns:
      synonyms map
    • dumpSynonymsAsync

      public RFuture<Map<String,List<String>>> dumpSynonymsAsync(String indexName)
      Description copied from interface: RSearchAsync
      Returns synonyms mapped by word by defined index name
      Specified by:
      dumpSynonymsAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      Returns:
      synonyms map
    • updateSynonyms

      public void updateSynonyms(String indexName, String synonymGroupId, String... terms)
      Description copied from interface: RSearch
      Updates synonyms
      Specified by:
      updateSynonyms in interface RSearch
      Parameters:
      indexName - index name
      synonymGroupId - synonym group id
      terms - terms
    • updateSynonymsAsync

      public RFuture<Void> updateSynonymsAsync(String indexName, String synonymGroupId, String... terms)
      Description copied from interface: RSearchAsync
      Updates synonyms
      Specified by:
      updateSynonymsAsync in interface RSearchAsync
      Parameters:
      indexName - index name
      synonymGroupId - synonym group id
      terms - terms
    • getIndexes

      public List<String> getIndexes()
      Description copied from interface: RSearch
      Returns list of all created indexes
      Specified by:
      getIndexes in interface RSearch
      Returns:
      list of indexes
    • getIndexesAsync

      public RFuture<List<String>> getIndexesAsync()
      Description copied from interface: RSearchAsync
      Returns list of all created indexes
      Specified by:
      getIndexesAsync in interface RSearchAsync
      Returns:
      list of indexes