public class Client extends Object implements Client
Modifier and Type | Class and Description |
---|---|
static class |
Client.IndexOptions
IndexOptions encapsulates flags for index creation and shuold be given to the client on index creation
|
Modifier and Type | Field and Description |
---|---|
protected Commands.CommandProvider |
commands |
FUZZY_FLAG, INCREMENT_FLAG, MAX_FLAG, PAYLOAD_FLAG
Constructor and Description |
---|
Client(String indexName,
String host,
int port) |
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) |
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 |
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)
Index a document already in redis as a HASH key.
|
Long |
addSuggestion(Suggestion suggestion,
boolean increment)
Add a word to the suggestion index for redis plugin
|
AggregationResult |
aggregate(AggregationRequest q) |
boolean |
createIndex(Schema schema,
Client.IndexOptions options)
Create the index definition in redis
|
boolean |
deleteDocument(String docId)
Delete a document from the index.
|
boolean |
dropIndex()
Drop the index and all associated keys, including documents
|
boolean |
dropIndex(boolean missingOk)
Drop the index and associated keys, including documents
|
String |
explain(Query q)
Generate an explanatory textual query tree for this query string
|
Document |
getDocument(String docId)
Get a document 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
|
boolean |
replaceDocument(String docId,
double score,
Map<String,Object> fields)
replaceDocument is a convenience for calling addDocument with replace=true
|
SearchResult |
search(Query q)
Search the index
|
boolean |
updateDocument(String docId,
double score,
Map<String,Object> fields)
Replace specific fields in a document.
|
protected Commands.CommandProvider commands
public 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)
public 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 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 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 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 SearchResult search(Query q)
search
in interface Client
q
- a Query
object with the query string and optional parametersSearchResult
object with the resultspublic AggregationResult aggregate(AggregationRequest q)
public String explain(Query q)
public boolean addDocument(String docId, double score, Map<String,Object> fields, boolean noSave, boolean replace, byte[] payload)
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)
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)
public boolean[] addDocuments(AddOptions options, Document... docs)
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 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 addHash(String docId, double score, boolean replace)
public Map<String,Object> getInfo()
public boolean deleteDocument(String docId)
deleteDocument
in interface Client
docId
- the document's idpublic Document getDocument(String docId)
getDocument
in interface Client
docId
- The document ID to retrievepublic 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 usageCopyright © 2018. All rights reserved.