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 |
DELETE_DOCUMENT, FUZZY_FLAG, INCREMENT_FLAG, MAX_FLAG, PAYLOAD_FLAG
Constructor and Description |
---|
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 |
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(AggregationBuilder q) |
AggregationResult |
aggregate(AggregationRequest q)
Deprecated.
use
aggregate(AggregationBuilder) instead |
boolean |
alterIndex(Schema.Field... fields)
Alter index add fields
|
void |
close() |
boolean |
createIndex(Schema schema,
Client.IndexOptions options)
Create the index definition in redis
|
boolean |
cursorDelete(long cursorId) |
AggregationResult |
cursorRead(long cursorId,
int count) |
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
|
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
|
Document |
getDocument(String docId,
boolean decode)
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
|
SearchResult |
search(Query q,
boolean decode)
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, 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, 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 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 boolean alterIndex(Schema.Field... fields)
fields
- list of fieldspublic 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)
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)
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[] deleteDocuments(boolean deleteDocuments, String... docIds)
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)
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)
docId
- The document ID 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 boolean cursorDelete(long cursorId)
cursorDelete
in interface Client
public AggregationResult cursorRead(long cursorId, int count)
cursorRead
in interface Client
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2019. All rights reserved.