updateByQuery #
Updates documents matching the provided search query.
Kuzzle uses the ElasticSearch Query DSL (opens new window) syntax.
An empty or null query will match all documents in the collection.
public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> updateByQuery(
final String index,
final String collection,
final ConcurrentHashMap<String, Object> searchQuery,
final ConcurrentHashMap<String, Object> changes) throws NotConnectedException, InternalException
public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> updateByQuery(
final String index,
final String collection,
final ConcurrentHashMap<String, Object> searchQuery,
final ConcurrentHashMap<String, Object> changes,
final UpdateOptions options) throws NotConnectedException, InternalException
Argument | Type | Description |
---|---|---|
index | String | Index name |
collection | String | Collection name |
searchQuery | ConcurrentHashMap<String, Object> | Query to match |
changes | ConcurrentHashMap<String, Object> | Partial changes to apply to the documents |
options | UpdateOptions ( null ) | Optional parameters |
options #
A UpdateOptions object.
The following options can be set:
Arguments | Type | Description |
---|---|---|
waitForRefresh | Boolean | If set to true , Kuzzle will wait for the persistence layer to finish indexing |
source | Boolean | If true, returns the updated document inside the response |
Returns #
A ConcurrentHashMap<String, ArrayList<Object>>
which has a successes
and errors
ArrayList<Object>
:
Each updated document is an object of the successes
array with the following properties:
Property | Type | Description |
---|---|---|
_source | ConcurrentHashMap<String, Object> | Updated document (if source option set to true) |
_id | String | ID of the udated document |
_version | Integer | Version of the document in the persistent data storage |
status | Integer | HTTP status code |
Each errored document is an object of the errors
array with the following properties:
Property | Type | Description |
---|---|---|
document | ConcurrentHashMap<String, Object> | Document that causes the error |
status | Integer | HTTP error status |
reason | String | Human readable reason |
Usage #
ConcurrentHashMap<String, Object> searchQuery = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> match = new ConcurrentHashMap<>();
match.put("capacity", 4);
searchQuery.put("match", match);
ConcurrentHashMap<String, Object> changes = new ConcurrentHashMap<>();
changes.put("capacity", 42);
ConcurrentHashMap<String, ArrayList<Object>> result = kuzzle
.getDocumentController()
.updateByQuery("nyc-open-data", "yellow-taxi", searchQuery, changes)
.get();
/*
{
successes=[
{
_id=<document-id>,
_source=<updated document> // if source set to true
status=200
},
{
_id=<document id>,
_source=<updated document> // if source set to true
status=200
}
],
errors=[]
}
*/
Edit this page on Github (opens new window)