SDK
SDK Dart v2.x
2

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.

Available since change-me

This method also supports the Koncorde Filters DSL to match documents by passing the lang argument with the value koncorde.
Koncorde filters will be translated into an Elasticsearch query.

Koncorde bool operator and regexp clause are not supported for search queries.


Arguments #

Future<SearchResult> search(
    String index,
    String collection, {
    Map<String, dynamic> query,
    int from,
    int size,
    String scroll,
    String lang
  })
ArgumentsTypeDescription
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)
lang
String
Specify the query language to use. By default, it's elasticsearch but koncorde can also be used.
Available since change-me

searchQuery body properties: #

An empty body matches all documents in the queried collection.

Return #

Returns a SearchResult object.

Usage #

With the ElasticSearch Query DSL syntax.

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

With the Koncorde Filters DSL syntax.

final result = await kuzzle
  .document
  .search('nyc-open-data', 'yellow-taxi', query: {
    'query': {
      'equals': {
          'category': 'suv'
        }
      }
  }, lang: 'koncorde');