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.

Signature

Copied to clipboard!
kuzzleio::SearchResult* searchSpecifications(const std::string& query);

kuzzleio::SearchResult* searchSpecifications(
    const std::string& query,
    const kuzzleio::query_options& options);

Arguments

Argument Type Description
query
const std::string&
JSON string representing the query to match
options
kuzzleio::query_options*
Query options

options

Options Type (default) Description
queuable
bool
(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
const std::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 kuzzleio::SearchResult.

Exceptions

Throws a kuzzleio::KuzzleException if there is an error. See how to handle errors.

Usage

Copied to clipboard!
try {
  kuzzleio::query_options options;
  options.from = 0;
  options.size = 2;

  kuzzleio::SearchResult* response = kuzzle->collection->searchSpecifications(
    R"({
      "query": {
        "match_all": {}
      }
    })",
    options);

  std::cout << "Successfully retrieved " << response->fetched() << " specifications" << std::endl;
} catch (kuzzleio::KuzzleException &e) {
  std::cerr << e.what() << std::endl;
}