SDK
SDK Golang v2.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

DeleteByQuery #

Deletes documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

Arguments #

DeleteByQuery(
  index string,
  collection string,
  query json.RawMessage,
  options types.QueryOptions) ([]string, error)

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
query
string
Query to match
options
types.QueryOptions
A struct containing query options

options #

Additional query options

OptionType
(default)
Description
Queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again
Refresh
string

("")
If set to wait_for, waits for the change to be reflected for search (up to 1s)

Return #

Returns the list of the deleted document ids.

Usage #

ids, err := kuzzle.Document.DeleteByQuery(
  "nyc-open-data",
  "yellow-taxi",
  json.RawMessage(`{"query": {"term": {"capacity": 7}}}`),
  nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Printf("Successfully deleted %d documents", len(ids))
}