Skip to content

RCBC-517: Support vector search prefilter #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/couchbase/search_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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?

Expand Down
Loading