Dart 2.x

search

Searches document.

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

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

When using a cursor with the scroll option, Elasticsearch has to duplicate the transaction log to keep the same result during the entire scroll session.
It can lead to memory leaks if a scroll duration too great is provided, or if too many scroll sessions are open simultaneously.

Available since Kuzzle 2.2.0

You can restrict the scroll session maximum duration under the services.storage.maxScrollDuration configuration key.


Arguments

Copied to clipboard!
Future<SearchResult> search(
    String index,
    String collection, {
    Map<String, dynamic> query,
    int from,
    int size,
    String scroll,
  })
Arguments Type Description
index
String
Index
collection
String
Collection
searchQuery
Map<String, dynamic>
Search query
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 1s; cf elasticsearch time limits)

searchQuery body properties:

An empty body matches all documents in the queried collection.

Return

Returns a SearchResult object.

Usage

Copied to clipboard!
final result = await kuzzle
  .document
  .search('nyc-open-data', 'yellow-taxi', query: {
    'query': {
      'match': {
        'category': 'suv'
      }
    }
  });