performDocumentSearch method

  1. @override
Stream<QueryResult> performDocumentSearch(
  1. DocumentSearchRequest request
)
override

Implementation

@override
Stream<QueryResult> performDocumentSearch(
  DocumentSearchRequest request,
) {
  // Do we need to delegate to the master?
  switch (request.reach) {
    case Reach.server:
      // No need
      break;
    default:
      // Yes we need
      return super.performDocumentSearch(request);
  }

  // Delegate to a search engine.
  try {
    return request.delegateTo(searchEngine);
  } on DatabaseException catch (error, stackTrace) {
    // Invoke callback
    final callback = onSearchError;
    if (callback != null) {
      return callback(this, request, error, stackTrace);
    }

    // By default, delegate to master.
    return master.performDocumentSearch(request);
  }
}