SearchResult constructor

SearchResult(
  1. Kuzzle kuzzle, {
  2. KuzzleRequest? request,
  3. KuzzleResponse? response,
})

Implementation

SearchResult(
  this.kuzzle, {
  this.request,
  this.response,
}) {
  lang = request!.lang;
  controller = request!.controller;
  searchAction = 'search';
  scrollAction = 'scroll';

  final result = response!.result as Map<String, dynamic>;

  if (result.containsKey('aggregations')) {
    aggregations = result['aggregations'] as Map<String, dynamic>?;
  }
  if (result.containsKey('hits')) {
    hits = result['hits'] as List<dynamic>?;
    fetched = hits!.length;
  }
  if (result.containsKey('total')) {
    total = result['total'] as int?;
  }
}