SDK
SDK Dart v1.x
2

# updateByQuery

Updates documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

An empty or null query will match all documents in the collection.


Copied to clipboard!
Future<Map<String, dynamic>> updateByQuery(
    String index,
    String collection,
    {
     Map<String, dynamic> searchQuery,
     Map<String, dynamic> changes,
    bool waitForRefresh = false,
    bool source = false,
  })
Argument Type Description
index
String
Index name
collection
String
Collection name
searchQuery
Map<String, dynamic>
Query to match
changes
Map<String, dynamic>
Partial changes to apply to the documents
waitForRefresh
bool

(false)
If set to true, Kuzzle will wait for the persistence layer to finish indexing
source
bool

(false)
If true, returns the updated document inside the response

# Returns

A Map<String, dynamic> which has a successes and errors: Each updated document is an object of the successes array with the following properties:

Property Type Description
_source
Map<String, dynamic>
Updated document (if source option set to true)
_id
String
ID of the udated document
_version
int
Version of the document in the persistent data storage
status
int
HTTP status code

Each errored document is an object of the errors array with the following properties:

Property Type Description
document
Map<String, dynamic>
Document that causes the error
status
int
HTTP error status
reason
String
Human readable reason

# Usage

Copied to clipboard!
final result = await kuzzle
  .document
  .updateByQuery('nyc-open-data', 'yellow-taxi', searchQuery: {
    'match': {
      'capacity': 4,
    },
  }, 
  changes: {
    'capacity': 42,
  });