Class: Couchbase::Protostellar::RequestGenerator::Search Private

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/protostellar/request_generator/search.rb

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

Constant Summary collapse

HIGHLIGHT_STYLE_MAP =

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

{
  :html => :HIGHLIGHT_STYLE_HTML,
  :ansi => :HIGHLIGHT_STYLE_ANSI,
  nil => :HIGHLIGHT_STYLE_DEFAULT,
}.freeze
MATCH_QUERY_OPERATOR_MAP =

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

{
  :or => :OPERATOR_OR,
  :and => :OPERATOR_AND,
}.freeze
SCAN_CONSISTENCY_MAP =

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

{
  :not_bounded => :SCAN_CONSISTENCY_NOT_BOUNDED,
}.freeze
DEFAULT_LIMIT =

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

10
DEFAULT_SKIP =

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

0

Instance Method Summary collapse

Instance Method Details

#search_query_request(index_name, query, options) ⇒ Object

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.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/couchbase/protostellar/request_generator/search.rb', line 46

def search_query_request(index_name, query, options)
  proto_opts = {
    scan_consistency: SCAN_CONSISTENCY_MAP[options.scan_consistency],
    include_explanation: options.explain,
    highlight_style: HIGHLIGHT_STYLE_MAP[options.highlight_style],
    disable_scoring: options.disable_scoring,
    include_locations: options.include_locations,
  }

  proto_opts[:highlight_fields] = options.highlight_fields unless options.highlight_fields.nil?
  proto_opts[:fields] = options.fields unless options.fields.nil?
  proto_opts[:sort] = get_sort(options) unless options.sort.nil?
  proto_opts[:limit] = options.limit || DEFAULT_LIMIT
  proto_opts[:skip] = options.skip || DEFAULT_SKIP
  proto_opts[:collections] = options.collections unless options.collections.nil?

  proto_req = Generated::Search::V1::SearchQueryRequest.new(
    query: create_query(query),
    index_name: index_name,
    **proto_opts
  )

  # Set the search facets in the request
  get_facets(options).each do |key, facet|
    proto_req.facets[key] = facet
  end

  create_search_request(proto_req, :search_query, options)
end