updateByQuery method

Future<Map<String, dynamic>> updateByQuery(
  1. String index,
  2. String collection, {
  3. required Map<String, dynamic> searchQuery,
  4. required Map<String, dynamic> changes,
  5. bool waitForRefresh = false,
  6. bool source = false,
  7. String? lang,
})

Updates documents matching the provided search query. Documents updated that way trigger real-time notifications.


Limitations

The request fails if the number of documents returned by the search query exceeds the documentsWriteCount server configuration (see the Configuring Kuzzle guide).

update a greater number of documents, either change the server configuration, or split the search query.

Implementation

Future<Map<String, dynamic>> updateByQuery(String index, String collection,
    {required Map<String, dynamic> searchQuery,
    required Map<String, dynamic> changes,
    bool waitForRefresh = false,
    bool source = false,
    String? lang}) async {
  final response = await kuzzle.query(KuzzleRequest(
    controller: name,
    action: 'updateByQuery',
    index: index,
    collection: collection,
    body: {'query': searchQuery, 'changes': changes},
    waitForRefresh: waitForRefresh,
    source: source,
    lang: lang,
  ));

  return response.result as Map<String, dynamic>;
}