Class: Couchbase::SearchRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/search_options.rb,
/code/couchbase-ruby-client/lib/couchbase/search_options.rb

Instance Method Summary collapse

Constructor Details

#new(search_query) ⇒ SearchRequest #new(vector_search) ⇒ SearchRequest

Creates a search request, used to perform operations against the Full Text Search (FTS) Couchbase service.

Overloads:

  • #new(search_query) ⇒ SearchRequest

    Will run an FTS SearchQuery

    Parameters:

  • #new(vector_search) ⇒ SearchRequest

    Will run a VectorSearch

    Parameters:

    Stability:

    • Uncommitted: This API may change in the future.



30
31
32
33
34
35
36
37
38
39
# File 'lib/couchbase/search_options.rb', line 30

def initialize(search)
  case search
  when SearchQuery
    @search_query = search
  when VectorSearch
    @vector_search = search
  else
    raise Error::InvalidArgument, "Search type must be either SearchQuery or VectorSearch, #{search.class} given"
  end
end

Instance Method Details

#search_query(query) ⇒ SearchRequest

Can be used to run a SearchQuery together with an existing VectorSearch Note that a maximum of one SearchQuery can be provided.

Parameters:

Returns:

Raises:



47
48
49
50
51
52
# File 'lib/couchbase/search_options.rb', line 47

def search_query(query)
  raise Error::InvalidArgument, "A SearchQuery has already been specified" unless @search_query.nil?

  @search_query = query
  self
end

#vector_search(query) ⇒ SearchRequest

Can be used to run a VectorSearch together with an existing SearchQuery Note that a maximum of one VectorSearch can be provided.

Parameters:

Returns:

Raises:

Stability:

  • Uncommitted: This API may change in the future.



62
63
64
65
66
67
# File 'lib/couchbase/search_options.rb', line 62

def vector_search(query)
  raise Error::InvalidArgument, "A VectorSearch has already been specified" unless @vector_search.nil?

  @vector_search = query
  self
end