Class: Couchbase::Options::Search

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

Overview

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(limit: nil, skip: nil, explain: false, highlight_style: nil, highlight_fields: nil, fields: nil, mutation_state: nil, disable_scoring: false, include_locations: false, collections: nil, sort: nil, facets: nil, transcoder: JsonTranscoder.new, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Search

Returns a new instance of Search.

Parameters:

  • limit (Integer) (defaults to: nil)

    limits the number of matches returned from the complete result set.

  • skip (Integer) (defaults to: nil)

    indicates how many matches are skipped on the result set before starting to return the matches

  • explain (Boolean) (defaults to: false)

    triggers inclusion of additional search result score explanations.

  • highlight_style (:html, :ansi, nil) (defaults to: nil)

    the style of highlighting in the result excerpts (if not specified, the server default will be used)

  • highlight_fields (Array<String>) (defaults to: nil)

    list of the fields to highlight

  • fields (Array<String>) (defaults to: nil)

    list of field values which should be retrieved for result documents, provided they were stored while indexing

  • mutation_state (MutationState) (defaults to: nil)

    the mutation tokens this query should be consistent with

  • disable_scoring (Boolean) (defaults to: false)

    If set to true, the server will not perform any scoring on the hits

  • include_locations (Boolean) (defaults to: false)

    UNCOMMITTED: If set to true, will include the vector of search_location in rows

  • collections (Array<String>, nil) (defaults to: nil)

    list of collections by which to filter the results

  • sort (Array<String, Cluster::SearchSort>) (defaults to: nil)

    Ordering rules to apply to the results. The list might contain either strings or special objects, that derive from Cluster::SearchSort. In case of String, the value represents the name of the field with optional - in front of the name, which will turn on descending mode for this field. One field is special is “_score” which will sort results by their score. When nothing specified, the Server will order results by their score descending, which is equivalent of “-_score”.

  • facets (Hash<String => Cluster::SearchFacet>) (defaults to: nil)

    facets allow to aggregate information collected on a particular result set

  • transcoder (JsonTranscoder, #decode(String)) (defaults to: JsonTranscoder.new)

    to use for the results

  • timeout (Integer, #in_milliseconds, nil) (defaults to: nil)
  • retry_strategy (Proc, nil) (defaults to: nil)

    the custom retry strategy, if set

  • client_context (Hash, nil) (defaults to: nil)

    the client context data, if set

  • parent_span (Span, nil) (defaults to: nil)

    if set holds the parent span, that should be used for this request

Yield Parameters:



2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
# File 'lib/couchbase/options.rb', line 2260

def initialize(limit: nil,
               skip: nil,
               explain: false,
               highlight_style: nil,
               highlight_fields: nil,
               fields: nil,
               mutation_state: nil,
               disable_scoring: false,
               include_locations: false,
               collections: nil,
               sort: nil,
               facets: nil,
               transcoder: JsonTranscoder.new,
               timeout: nil,
               retry_strategy: nil,
               client_context: nil,
               parent_span: nil)
  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
  @limit = limit
  @skip = skip
  @explain = explain
  @highlight_style = highlight_style
  @highlight_fields = highlight_fields
  @fields = fields
  @disable_scoring = disable_scoring
  @include_locations = include_locations
  @collections = collections
  @sort = sort
  @facets = facets
  @transcoder = transcoder
  @scan_consistency = :not_bounded
  @mutation_state = mutation_state
  yield self if block_given?
end

Instance Attribute Details

#collectionsArray<String>?

Returns:

  • (Array<String>, nil)


2227
2228
2229
# File 'lib/couchbase/options.rb', line 2227

def collections
  @collections
end

#disable_scoringBoolean

Returns:

  • (Boolean)


2225
2226
2227
# File 'lib/couchbase/options.rb', line 2225

def disable_scoring
  @disable_scoring
end

#explainBoolean

Returns:

  • (Boolean)


2221
2222
2223
# File 'lib/couchbase/options.rb', line 2221

def explain
  @explain
end

#facetsHash<String => Cluster::SearchFacet>

Returns:



2229
2230
2231
# File 'lib/couchbase/options.rb', line 2229

def facets
  @facets
end

#fieldsArray<String>

Returns:

  • (Array<String>)


2224
2225
2226
# File 'lib/couchbase/options.rb', line 2224

def fields
  @fields
end

#highlight_fieldsArray<String>

Returns:

  • (Array<String>)


2223
2224
2225
# File 'lib/couchbase/options.rb', line 2223

def highlight_fields
  @highlight_fields
end

#highlight_styleSymbol

Returns:

  • (Symbol)


2222
2223
2224
# File 'lib/couchbase/options.rb', line 2222

def highlight_style
  @highlight_style
end

#include_locationsBoolean

Returns:

  • (Boolean)


2226
2227
2228
# File 'lib/couchbase/options.rb', line 2226

def include_locations
  @include_locations
end

#limitInteger

Returns:

  • (Integer)


2219
2220
2221
# File 'lib/couchbase/options.rb', line 2219

def limit
  @limit
end

#scan_consistency=(level) ⇒ void

Note:

overrides consistency level set by #consistent_with

This method returns an undefined value.

Customizes the consistency guarantees for this query

Parameters:

  • level (:not_bounded)

    the scan consistency to be used for this query

    :not_bounded

    The engine will return whatever state it has at the time of query



2315
2316
2317
2318
# File 'lib/couchbase/options.rb', line 2315

def scan_consistency=(level)
  @mutation_state = nil if @mutation_state
  @scan_consistency = level
end

#skipInteger

Returns:

  • (Integer)


2220
2221
2222
# File 'lib/couchbase/options.rb', line 2220

def skip
  @skip
end

#sortArray<String, Cluster::SearchSort>

Returns:



2228
2229
2230
# File 'lib/couchbase/options.rb', line 2228

def sort
  @sort
end

#transcoderJsonTranscoder, #decode(String)

Returns:



2230
2231
2232
# File 'lib/couchbase/options.rb', line 2230

def transcoder
  @transcoder
end

Instance Method Details

#consistent_with(mutation_state) ⇒ void

Note:

overrides consistency level set by #scan_consistency=

This method returns an undefined value.

Sets the mutation tokens this query should be consistent with

Parameters:

  • mutation_state (MutationState)

    the mutation state containing the mutation tokens



2302
2303
2304
2305
# File 'lib/couchbase/options.rb', line 2302

def consistent_with(mutation_state)
  @scan_consistency = nil if @scan_consistency
  @mutation_state = mutation_state
end