Skip to content

Commit 0aca8ef

Browse files
authored
RCBC-517: Support vector search prefilter (#180)
1 parent 00f1858 commit 0aca8ef

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lib/couchbase/search_options.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ def to_h
321321
# @yieldparam [BooleanFieldQuery] query
322322
#
323323
# @return [BooleanFieldQuery]
324-
def self.boolean_field(value)
325-
BooleanFieldQuery.new(value)
324+
def self.boolean_field(value, &)
325+
BooleanFieldQuery.new(value, &)
326326
end
327327

328328
# Allow to match `true`/`false` in a field mapped as boolean.
@@ -1073,6 +1073,9 @@ class VectorQuery
10731073
# @return [Float, nil]
10741074
attr_accessor :boost
10751075

1076+
# @return [SearchQuery, nil]
1077+
attr_accessor :prefilter
1078+
10761079
# Constructs a +VectorQuery+ instance
10771080
#
10781081
# @overload initialize(vector_field_name, vector_query)
@@ -1111,6 +1114,8 @@ def to_h
11111114
boost: boost,
11121115
}.compact
11131116

1117+
h[:filter] = prefilter.to_h unless prefilter.nil?
1118+
11141119
raise Error::InvalidArgument, "The vector cannot be nil" if !h.include?(:vector) && !h.include?(:vector_base64)
11151120
raise Error::InvalidArgument, "The vector query cannot be an empty array" if h.include?(:vector) && h[:vector].empty?
11161121

0 commit comments

Comments
 (0)