Count #
Counts documents in a collection.
A query can be provided to alter the count result, otherwise returns the total number of documents in the collection.
Kuzzle uses the ElasticSearch Query DSL syntax.
Arguments #
Count(
index string,
collection string,
query json.RawMessage,
options types.QueryOptions) (int, error)
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
query | json.RawMessage | Query to match |
options | types.QueryOptions | A struct containing query options |
options #
Additional query options
Option | Type (default) | Description |
---|---|---|
Queuable | bool ( true ) | If true, queues the request during downtime, until connected to Kuzzle again |
Return #
Returns the number of documents matching the given query.
Usage #
query := json.RawMessage(`{"query": {"match": {"licence": "valid"}}}`)
count, err := kuzzle.Document.Count("nyc-open-data", "yellow-taxi", query, nil)
if err != nil {
log.Fatal(err)
} else {
fmt.Printf("Found %d documents matching licence:valid\n", count)
}
Edit this page on Github(opens new window)