search #
Searches for assets.
See also document:search API action.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/_/device-manager/:index/assets/_search[?from=<int>][&size=<int>][&scroll=<time to live>][&lang=<query language>]
Method: POST or GET
Body:
{
"query": {
// ...
},
"aggregations": {
// ...
},
"sort": [
// ...
]
}
Other protocols #
{
"index": "<index>",
"controller": "device-manager/asset",
"action": "search",
"body": {
"query": {
// ...
},
"aggregations": {
// ...
},
"sort": [
// ...
]
},
// optional:
"from": "<starting offset>",
"size": "<page size>",
"scroll": "<scroll duration>",
"lang": "<query language>"
}
Kourou #
kourou device-manager/asset:search <index> --body '{
query: {
// search query
}
}'
Arguments #
index
: index name
Optional: #
from
: paginates search results by defining the offset from the first result you want to fetch. Usually used with thesize
argumentscroll
: creates a forward-only result cursor. This option must be set with a time duration, at the end of which the cursor is destroyed. If set, a cursor identifier namedscrollId
is returned in the results. This cursor can then be moved forward using the scroll API actionsize
: set the maximum number of documents returned per result pagelang
: specify the query language to use. By default, it'selasticsearch
butkoncorde
can also be used.
Body properties #
Optional: #
query
: the search query itself, using the ElasticSearch Query DSL or the Koncorde Filters DSL syntax.aggregations
: control how the search result 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.
Only the following fields are available in the top level of the search body: aggregations
, aggs
, collapse
, explain
, from
, highlight
, query
, search_timeout
, size
, sort
, _name
, _source
, _source_excludes
, _source_includes
Response #
Returns a paginated search result set, with the following properties:
aggregations
: provides aggregation information. Present only if anaggregations
object has been provided in the search bodyhits
: array of found documents. Each document has the following properties:_id
: document unique identifier_score
: relevance score_source
: new document contenthighlight
: optional result from highlight API
remaining
: remaining documents that can be fetched. Present only if thescroll
argument has been supplied -scrollId
: identifier to the next page of result. Present only if thescroll
argument has been suppliedtotal
: total number of found documents. Can be greater than the number of documents in a result page, meaning that other matches than the one retrieved are available
{
"status": 200,
"error": null,
"index": "<index>",
"action": "search",
"controller": "device-manager/asset",
"requestId": "<unique request identifier>",
"result": {
"scrollId": "<scroll id>",
"hits": [
{
"_id": "<asset unique identifier>",
"_score": 1,
"_source": {
// asset content
}
},
{
"_id": "<another asset unique identifier>",
"_score": 1,
"_source": {
// asset content
}
}
],
// Present only if aggregation parameters have been set
"aggregations": {
"aggs_name": {}
},
"total": 42
}
}
Edit this page on Github(opens new window)