findNearest method

Query<T> findNearest(
  1. String field,
  2. Map<String, dynamic> query,
  3. {String? metric,
  4. int? topK,
  5. num? threshold}
)

Creates a v2 vector similarity query.

Implementation

Query<T> findNearest(
  String field,
  Map<String, dynamic> query, {
  String? metric,
  int? topK,
  num? threshold,
}) {
  validateVectorSearchQuery(query);

  if (topK != null && topK <= 0) {
    throw Utils.oracledbErrorHandler(
      400,
      'findNearest topK must be a positive integer.',
      null,
    );
  }
  if (threshold != null && threshold.isNaN) {
    throw Utils.oracledbErrorHandler(
      400,
      'findNearest threshold must be a number.',
      null,
    );
  }

  return withVectorSearch({
    'field': field,
    'query': deepClone(query),
    'metric': metric,
    'topK': topK,
    'threshold': threshold,
  });
}