Class: Couchbase::VectorSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/search_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(vector_queries, options = Options::VectorSearch::DEFAULT) ⇒ VectorSearch

Constructs a VectorSearch instance, which allows one or more individual vector queries to be executed.

Parameters:



1055
1056
1057
1058
# File 'lib/couchbase/search_options.rb', line 1055

def initialize(vector_queries, options = Options::VectorSearch::DEFAULT)
  @vector_queries = vector_queries.respond_to?(:each) ? vector_queries : [vector_queries]
  @options = options
end

Instance Method Details

#to_backendObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1061
1062
1063
1064
1065
# File 'lib/couchbase/search_options.rb', line 1061

def to_backend
  raise Error::InvalidArgument, "Vector search requires at least one vector query" if @vector_queries.empty?

  {vector_queries: @vector_queries.map(&:to_h).to_json}.merge(@options.to_backend)
end