SDK
SDK Golang v3.x
2

SearchSpecifications #

Searches collection specifications.

There is a limit to how many items can be returned by a single search query. That limit is by default set at 10000, and you can't get over it even with the from and size pagination options.

When processing a large number of items (i.e. more than 1000), it is advised to paginate the results using SearchResult.next rather than increasing the size parameter.

Arguments #

SearchSpecifications(
  query json.RawMessage,
  options types.QueryOptions) (*types.SearchResult, error)

ArgumentTypeDescription
query
json.RawMessage
Query to match
options
types.QueryOptions
A struct containing query options

options #

OptionsType (default)Description
queuable
boolean
(true)
If true, queues the request during downtime, until connected to Kuzzle again
from
int

(0)
Offset of the first document to fetch
size
int

(10)
Maximum number of documents to retrieve per page
scroll
string

("")
When set, gets a forward-only cursor having its ttl set to the given value (ie 30s; cf elasticsearch time limits)

Query properties #

Optional: #

An empty body matches all documents in the queried collection.

Return #

Returns a types.SearchResult struct

Usage #

options := types.NewQueryOptions()
options.SetFrom(0)
options.SetSize(2)
response, err := kuzzle.Collection.SearchSpecifications(json.RawMessage(`{
  "query": {
    "match_all": {} 
  }
}`), options)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Printf("Successfully retrieved %d specifications", response.Total)
}