Skip to content

Commit

Permalink
CBL-6667: Remove LIMIT restriction in vector search (#2217)
Browse files Browse the repository at this point in the history
The removal of restriction of "LIMIT > 0" matches that in 4.0 line.
  • Loading branch information
jianminzhao authored Jan 28, 2025
1 parent b164025 commit 9eaeba8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions LiteCore/Query/QueryParser+VectorSearch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Dict.hh"
#include "Logging.hh"
#include "MutableArray.hh"
#include <algorithm>

#ifdef COUCHBASE_ENTERPRISE

Expand Down Expand Up @@ -101,9 +102,9 @@ namespace litecore {
int64_t maxResults;
auto limitVal = getCaseInsensitive(select, "LIMIT");
require(limitVal, "a LIMIT must be given when using APPROX_VECTOR_DISTANCE()");
maxResults = limitVal->asInt();
require(limitVal->isInteger() && maxResults > 0,
"LIMIT must be a positive integer when using APPROX_VECTOR_DISTANCE()");
require(limitVal->isInteger(),
"a LIMIT must be given as a literal when using APPROX_VECTOR_DISTANCE()");
maxResults = std::max<int64_t>(limitVal->asInt(), 0);
require(maxResults <= kMaxMaxResults, "LIMIT must not exceed %u when using APPROX_VECTOR_DISTANCE()",
kMaxMaxResults);

Expand Down

0 comments on commit 9eaeba8

Please sign in to comment.