diff --git a/lib/couchbase/search_options.rb b/lib/couchbase/search_options.rb index d8132790..6c5df820 100644 --- a/lib/couchbase/search_options.rb +++ b/lib/couchbase/search_options.rb @@ -321,8 +321,8 @@ def to_h # @yieldparam [BooleanFieldQuery] query # # @return [BooleanFieldQuery] - def self.boolean_field(value) - BooleanFieldQuery.new(value) + def self.boolean_field(value, &) + BooleanFieldQuery.new(value, &) end # Allow to match `true`/`false` in a field mapped as boolean. @@ -1073,6 +1073,9 @@ class VectorQuery # @return [Float, nil] attr_accessor :boost + # @return [SearchQuery, nil] + attr_accessor :prefilter + # Constructs a +VectorQuery+ instance # # @overload initialize(vector_field_name, vector_query) @@ -1111,6 +1114,8 @@ def to_h boost: boost, }.compact + h[:filter] = prefilter.to_h unless prefilter.nil? + raise Error::InvalidArgument, "The vector cannot be nil" if !h.include?(:vector) && !h.include?(:vector_base64) raise Error::InvalidArgument, "The vector query cannot be an empty array" if h.include?(:vector) && h[:vector].empty?