public class Client extends Object
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 |
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
|
Modifier and Type | Method and Description |
---|---|
boolean |
addDocument(String docId,
double score,
Map<String,Object> fields)
See above
|
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)
See above
|
boolean |
addHash(String docId,
double score,
boolean replace)
Index a document already in redis as a HASH key.
|
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
|
String |
explain(Query q)
Generate an explanatory textual query tree for this query string
|
Map<String,Object> |
getInfo()
Get the index info, including memory consumption and other statistics.
|
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 boolean createIndex(Schema schema, Client.IndexOptions options)
schema
- a schema definition, see Schema
options
- index option flags, see Client.IndexOptions
public SearchResult search(Query q)
q
- a Query
object with the query string and optional parametersSearchResult
object with the resultspublic String explain(Query q)
q
- The query to explainpublic 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 replaceDocument(String docId, double score, Map<String,Object> fields)
public boolean updateDocument(String docId, double score, Map<String,Object> fields)
docId
- score
- fields
- public boolean addDocument(String docId, double score, Map<String,Object> fields)
public boolean addHash(String docId, double score, boolean replace)
docId
- the id of the document in redis. This must match an existing, unindexed HASH keyscore
- the document's index score, between 0 and 1replace
- if set, and the document already exists, we reindex and update itpublic Map<String,Object> getInfo()
public boolean deleteDocument(String docId)
docId
- the document's idpublic boolean dropIndex()
Copyright © 2018. All rights reserved.