public class Client extends Object implements Client
Modifier and Type | Class and Description |
---|---|
static class |
Client.IndexOptions
IndexOptions encapsulates flags for index creation and should be given to the client on index creation
|
Modifier and Type | Field and Description |
---|---|
protected Commands.CommandProvider |
commands |
DELETE_DOCUMENT, FUZZY_FLAG, INCREMENT_FLAG, MAX_FLAG, PAYLOAD_FLAG
Constructor and Description |
---|
Client(String indexName,
redis.clients.jedis.Jedis jedis) |
Client(String indexName,
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool)
Create a new client to a RediSearch index
|
Client(String indexName,
String host,
int port)
Create a new client to a RediSearch index
|
Client(String indexName,
String host,
int port,
int timeout,
int poolSize)
Create a new client to a RediSearch index
|
Client(String indexName,
String host,
int port,
int timeout,
int poolSize,
String password)
Create a new client to a RediSearch index
|
Client(String indexName,
String masterName,
Set<String> sentinels)
Create a new client to a RediSearch index with JediSentinelPool implementation.
|
Client(String indexName,
String masterName,
Set<String> sentinels,
int timeout,
int poolSize)
Create a new client to a RediSearch index with JediSentinelPool implementation.
|
Client(String indexName,
String master,
Set<String> sentinels,
int timeout,
int poolSize,
String password)
Create a new client to a RediSearch index with JediSentinelPool implementation.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAlias(String name)
Add an alias to the index.
|
boolean |
addDocument(Document doc)
Add a document to the index
|
boolean |
addDocument(Document doc,
AddOptions options)
Add a document to the index
|
boolean |
addDocument(String docId,
double score,
Map<String,Object> fields)
|
boolean |
addDocument(String docId,
double score,
Map<String,Object> fields,
boolean noSave,
boolean replace,
byte[] payload)
Add a single document to the query
|
boolean |
addDocument(String docId,
Map<String,Object> fields)
|
boolean[] |
addDocuments(AddOptions options,
Document... docs)
Add a batch of documents to the index
|
boolean[] |
addDocuments(Document... docs)
|
boolean |
addHash(String docId,
double score,
boolean replace)
Deprecated.
does support starting from RediSearch 2.0
|
Long |
addSuggestion(Suggestion suggestion,
boolean increment)
Add a word to the suggestion index for redis plugin
|
long |
addSynonym(String... terms)
Deprecated.
|
AggregationResult |
aggregate(AggregationBuilder q)
Search and Aggregate the index
|
AggregationResult |
aggregate(AggregationRequest q)
Deprecated.
use
aggregate(AggregationBuilder) instead |
boolean |
alterIndex(Schema.Field... fields)
Alter index add fields
|
void |
close() |
redis.clients.jedis.Jedis |
connection() |
boolean |
createIndex(Schema schema,
Client.IndexOptions options)
Create the index definition in redis
|
boolean |
cursorDelete(long cursorId)
Delete a cursor from the index.
|
AggregationResult |
cursorRead(long cursorId,
int count)
Read from an existing cursor
|
boolean |
deleteAlias(String name)
remove an alias from an index.
|
boolean |
deleteDocument(String docId)
Delete a document from the index (doesn't delete the document).
|
boolean |
deleteDocument(String docId,
boolean deleteDocument)
Delete a document from the index.
|
boolean[] |
deleteDocuments(boolean deleteDocuments,
String... docIds)
Delete a documents from the index
|
Long |
deleteSuggestion(String entry)
Deletes a string from a suggestion
|
boolean |
dropIndex()
Drop the index and all associated keys, including documents
|
boolean |
dropIndex(boolean missingOk)
Drop the index and associated keys, including documents
|
Map<String,List<String>> |
dumpSynonym() |
String |
explain(Query q)
Generate an explanatory textual query tree for this query string
|
Map<String,String> |
getAllConfig()
Get all configuration options, consisting of the option's name and current value
|
String |
getConfig(ConfigOption option)
Get runtime configuration option value
|
Document |
getDocument(String docId)
Get a document from the index
|
Document |
getDocument(String docId,
boolean decode)
Get a document from the index
|
List<Document> |
getDocuments(boolean decode,
String... docIds)
Get a documents from the index
|
List<Document> |
getDocuments(String... docIds)
Get a documents from the index
|
Map<String,Object> |
getInfo()
Get the index info, including memory consumption and other statistics.
|
List<Suggestion> |
getSuggestion(String prefix,
SuggestionOptions suggestionOptions)
Request the Suggestions based on the prefix
|
Long |
getSuggestionLength()
Gets the size of an auto-complete suggestion
|
boolean |
replaceDocument(String docId,
double score,
Map<String,Object> fields)
replaceDocument is a convenience for calling addDocument with replace=true
|
boolean |
replaceDocument(String docId,
double score,
Map<String,Object> fields,
String filter)
replaceDocument is a convenience for calling addDocument with replace=true
|
SearchResult |
search(Query q)
Search the index
|
SearchResult |
search(Query q,
boolean decode)
Search the index
|
SearchResult[] |
searchBatch(Query... queries)
Search the index
|
boolean |
setConfig(ConfigOption option,
String value)
Set runtime configuration option
|
boolean |
updateAlias(String name)
Update an alias from an index.
|
boolean |
updateDocument(String docId,
double score,
Map<String,Object> fields)
Replace specific fields in a document.
|
boolean |
updateDocument(String docId,
double score,
Map<String,Object> fields,
String filter)
Replace specific fields in a document.
|
boolean |
updateSynonym(long synonymGroupId,
String... terms)
Deprecated.
|
boolean |
updateSynonym(String synonymGroupId,
String... terms)
Updates a synonym group.
|
protected Commands.CommandProvider commands
public Client(String indexName, redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool)
indexName
- the name of the index we are connecting to or creatingpool
- jedis connection pool to be usedpublic Client(String indexName, redis.clients.jedis.Jedis jedis)
public Client(String indexName, String host, int port)
indexName
- the name of the index we are connecting to or creatinghost
- the redis hostport
- the redis potpublic Client(String indexName, String host, int port, int timeout, int poolSize)
indexName
- the name of the index we are connecting to or creatinghost
- the redis hostport
- the redis potpublic Client(String indexName, String host, int port, int timeout, int poolSize, String password)
indexName
- the name of the index we are connecting to or creatinghost
- the redis hostport
- the redis potpassword
- the password for authentication in a password protected Redis serverpublic Client(String indexName, String master, Set<String> sentinels, int timeout, int poolSize, String password)
indexName
- the name of the index we are connecting to or creatingmaster
- the masterName to connect from list of masters monitored by sentinelssentinels
- the set of sentinels monitoring the clustertimeout
- the timeout in millisecondspoolSize
- the poolSize of JedisSentinelPoolpassword
- the password for authentication in a password protected Redis serverpublic Client(String indexName, String masterName, Set<String> sentinels, int timeout, int poolSize)
The Client is initialized with following default values for JedisSentinelPool
indexName
- the name of the index we are connecting to or creatingmasterName
- the masterName to connect from list of masters monitored by sentinelssentinels
- the set of sentinels monitoring the clustertimeout
- the timeout in millisecondspoolSize
- the poolSize of JedisSentinelPoolpublic Client(String indexName, String masterName, Set<String> sentinels)
The Client is initialized with following default values for JedisSentinelPool
indexName
- the name of the index we are connecting to or creatingmasterName
- the masterName to connect from list of masters monitored by sentinelssentinels
- the set of sentinels monitoring the clusterpublic redis.clients.jedis.Jedis connection()
connection
in interface Client
public boolean createIndex(Schema schema, Client.IndexOptions options)
createIndex
in interface Client
schema
- a schema definition, see Schema
options
- index option flags, see Client.IndexOptions
public boolean alterIndex(Schema.Field... fields)
alterIndex
in interface Client
fields
- list of fieldspublic boolean setConfig(ConfigOption option, String value)
public String getConfig(ConfigOption option)
public Map<String,String> getAllConfig()
getAllConfig
in interface Client
public boolean addAlias(String name)
Client
public boolean updateAlias(String name)
Client
updateAlias
in interface Client
public boolean deleteAlias(String name)
Client
deleteAlias
in interface Client
public SearchResult[] searchBatch(Query... queries)
searchBatch
in interface Client
queries
- an array of Query
objects with the query strings and optional parametersSearchResult
object with the resultspublic SearchResult search(Query q)
search
in interface Client
q
- a Query
object with the query string and optional parametersSearchResult
object with the resultspublic SearchResult search(Query q, boolean decode)
search
in interface Client
q
- a Query
object with the query string and optional parametersdecode
- false
- keeps the fields value as byte[]SearchResult
object with the results@Deprecated public AggregationResult aggregate(AggregationRequest q)
aggregate(AggregationBuilder)
insteadpublic AggregationResult aggregate(AggregationBuilder q)
Client
aggregate
in interface Client
q
- a AggregationBuilder
object with the query string and optional aggregation parametersAggregationResult
object with the resultspublic String explain(Query q)
public boolean addDocument(String docId, double score, Map<String,Object> fields, boolean noSave, boolean replace, byte[] payload)
addDocument
in interface Client
docId
- the id of the document. It cannot belong to a document already in the index unless replace is setscore
- the document's score, floating point number between 0 and 1fields
- a map of the document's fieldsnoSave
- if set, we only index the document and do not save its contents. This allows fetching just doc idsreplace
- if set, and the document already exists, we reindex and update itpayload
- if set, we can save a payload in the index to be retrieved or evaluated by scoring functions on the serverpublic boolean addDocument(Document doc)
addDocument
in interface Client
doc
- The document to addpublic boolean addDocument(Document doc, AddOptions options)
addDocument
in interface Client
doc
- The document to addoptions
- Options for the operationpublic boolean[] addDocuments(Document... docs)
addDocuments
in interface Client
docs
- The document to addpublic boolean[] addDocuments(AddOptions options, Document... docs)
addDocuments
in interface Client
options
- Options for the operationdocs
- The documents to addpublic boolean replaceDocument(String docId, double score, Map<String,Object> fields)
replaceDocument
in interface Client
docId
- score
- fields
- public boolean replaceDocument(String docId, double score, Map<String,Object> fields, String filter)
replaceDocument
in interface Client
docId
- score
- fields
- filter
- updates the document only if a boolean expression applies to the documentpublic boolean updateDocument(String docId, double score, Map<String,Object> fields)
updateDocument
in interface Client
docId
- the id of the document. It cannot belong to a document already in the index unless replace is setscore
- the document's score, floating point number between 0 and 1fields
- a map of the document's fieldspublic boolean updateDocument(String docId, double score, Map<String,Object> fields, String filter)
updateDocument
in interface Client
docId
- the id of the document. It cannot belong to a document already in the index unless replace is setscore
- the document's score, floating point number between 0 and 1fields
- a map of the document's fieldsfilter
- updates the document only if a boolean expression applies to the documentpublic boolean addDocument(String docId, double score, Map<String,Object> fields)
addDocument
in interface Client
public boolean addDocument(String docId, Map<String,Object> fields)
addDocument
in interface Client
@Deprecated public boolean addHash(String docId, double score, boolean replace)
public Map<String,Object> getInfo()
public boolean[] deleteDocuments(boolean deleteDocuments, String... docIds)
deleteDocuments
in interface Client
deleteDocuments
- if true
also deletes the actual document ifs it is in the indexdocIds
- the document's idspublic boolean deleteDocument(String docId)
deleteDocument
in interface Client
docId
- the document's iddeleteDocument(String, boolean)
public boolean deleteDocument(String docId, boolean deleteDocument)
deleteDocument
in interface Client
docId
- the document's iddeleteDocument
- if true
also deletes the actual document if it is in the indexpublic Document getDocument(String docId)
getDocument
in interface Client
docId
- The document ID to retrieveString
getDocument(String, boolean)
public Document getDocument(String docId, boolean decode)
getDocument
in interface Client
docId
- The document ID to retrievedecode
- false
- keeps the fields value as byte[]public List<Document> getDocuments(String... docIds)
getDocuments
in interface Client
docIds
- The document IDs to retrievepublic List<Document> getDocuments(boolean decode, String... docIds)
getDocuments
in interface Client
docIds
- The document IDs to retrievedecode
- false
- keeps the fields value as byte[]public boolean dropIndex()
public boolean dropIndex(boolean missingOk)
public Long addSuggestion(Suggestion suggestion, boolean increment)
Client
addSuggestion
in interface Client
suggestion
- the Suggestion to be addedincrement
- if we should increment this suggestion or notpublic List<Suggestion> getSuggestion(String prefix, SuggestionOptions suggestionOptions)
Client
getSuggestion
in interface Client
prefix
- the partial wordsuggestionOptions
- the options on what you need returned and other usagepublic Long deleteSuggestion(String entry)
Client
deleteSuggestion
in interface Client
public Long getSuggestionLength()
Client
getSuggestionLength
in interface Client
public boolean cursorDelete(long cursorId)
Client
cursorDelete
in interface Client
cursorId
- the cursor's idpublic AggregationResult cursorRead(long cursorId, int count)
Client
cursorRead
in interface Client
cursorId
- the cursor's idcount
- limit the amount of returned resultsAggregationResult
object with the results@Deprecated public long addSynonym(String... terms)
Client
addSynonym
in interface Client
@Deprecated public boolean updateSynonym(long synonymGroupId, String... terms)
Client
updateSynonym
in interface Client
public boolean updateSynonym(String synonymGroupId, String... terms)
Client
updateSynonym
in interface Client
public Map<String,List<String>> dumpSynonym()
dumpSynonym
in interface Client
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2021 RedisLabs. All rights reserved.