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 #
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: #
query
: the search query itself, using the ElasticSearch Query DSL syntax.aggregations
: controls how the search results should be aggregatedsort
: contains a list of fields, used to sort search results, in order of importance.
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 #
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;
}