deleteByQuery #
Deletes documents matching the provided search query.
Kuzzle uses the ElasticSearch Query DSL syntax.
This method also supports the Koncorde Filters DSL to match documents by passing the lang
argument with the value koncorde
.
Koncorde filters will be translated into an Elasticsearch query.
Koncorde bool
operator and regexp
clauses are not supported for search queries.
An empty or null query will match all documents in the collection.
:::: tabs ::: tab Java
Arguments #
public CompletableFuture<ArrayList<String>> deleteByQuery(
String index,
String collection,
Map<String, Object> searchQuery) throws NotConnectedException, InternalException
public CompletableFuture<ArrayList<String>> deleteByQuery(
String index,
String collection,
Map<String, Object> searchQuery,
Lang lang) throws NotConnectedException, InternalException
public CompletableFuture<ArrayList<String>> deleteByQuery(
String index,
String collection,
Map<String, Object> searchQuery,
Boolean waitForRefresh) throws NotConnectedException, InternalException
public CompletableFuture<ArrayList<String>> deleteByQuery(
String index,
String collection,
Map<String, Object> searchQuery,
Boolean waitForRefresh,
Lang lang) throws NotConnectedException, InternalException
Argument | Type | Description |
---|---|---|
index | String | Index name |
collection | String | Collection name |
searchQuery | Map<String, Object> | Query to match |
waitForRefresh | Boolean(optional) | If set to true , Kuzzle will wait for the persistence layer to finish indexing |
lang | Lang | Specify the query language to use. By default, it's elasticsearch but koncorde can also be used. Available since 1.1.0 |
Returns #
Returns an ArrayList<String>
containing the deleted document ids.
Usage #
With the ElasticSearch Query DSL syntax.
Map<String, Object> searchQuery = new HashMap<>();
Map<String, Object> query = new HashMap<>();
Map<String, Object> match = new HashMap<>();
match.put("capacity", 4);
query.put("match", match);
searchQuery.put("query", query);
ArrayList<String> result = kuzzle
.getDocumentController()
.deleteByQuery("nyc-open-data", "yellow-taxi", searchQuery)
.get();
With the Koncorde Filters DSL syntax.
Map<String, Object> searchQuery = new HashMap<>();
Map<String, Object> query = new HashMap<>();
Map<String, Object> equals = new HashMap<>();
equals.put("capacity", 4);
query.put("equals", equals);
searchQuery.put("query", query);
ArrayList<String> result = kuzzle
.getDocumentController()
.deleteByQuery("nyc-open-data", "yellow-taxi", searchQuery, Lang.KONCORDE)
.get();
::: ::: tab Kotlin
Arguments #
fun deleteByQuery(
index: String,
collection: String,
searchQuery: Map<String, Any?>,
waitForRefresh: Boolean? = null,
lang: Lang = Lang.ELASTICSEARCH): CompletableFuture<ArrayList<String>>
Argument | Type | Description |
---|---|---|
index | String | Index name |
collection | String | Collection name |
searchQuery | Map<String, Any?> | Query to match |
waitForRefresh | Boolean(optional) | If set to true , Kuzzle will wait for the persistence layer to finish indexing |
lang | Lang | Specify the query language to use. By default, it's elasticsearch but koncorde can also be used. Available since 1.1.0 |
Returns #
Returns an ArrayList<String>
containing the deleted document ids.
Usage #
With the ElasticSearch Query DSL syntax.
val searchQuery: Map<String, Any?> = HashMap<String, Any?>().apply {
put(
"query",
HashMap<String, Any?>().apply {
put(
"match",
HashMap<String, Any?>().apply {
put("capacity", 4)
}
)
}
)
}
val result: ArrayList<String> = kuzzle
.documentController
.deleteByQuery("nyc-open-data", "yellow-taxi", searchQuery)
.get()
With the Koncorde Filters DSL syntax.
val searchQuery: Map<String, Any?> = HashMap<String, Any?>().apply {
put("query", HashMap<String, Any?>().apply {
put("equals", HashMap<String, Any?>().apply {
put("capacity", 4)
})
})
}
val result: ArrayList<String> = kuzzle
.documentController
.deleteByQuery("nyc-open-data", "yellow-taxi", searchQuery, lang = Lang.KONCORDE)
.get()
::: ::::