Class: Couchbase::Options::Search

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

Overview

Constant Summary collapse

DEFAULT =

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.

Search.new.freeze

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.

Yield Parameters:



2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
# File 'lib/couchbase/options.rb', line 2296

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>?



2263
2264
2265
# File 'lib/couchbase/options.rb', line 2263

def collections
  @collections
end

#disable_scoringBoolean



2261
2262
2263
# File 'lib/couchbase/options.rb', line 2261

def disable_scoring
  @disable_scoring
end

#explainBoolean



2257
2258
2259
# File 'lib/couchbase/options.rb', line 2257

def explain
  @explain
end

#facetsHash<String => Cluster::SearchFacet>



2265
2266
2267
# File 'lib/couchbase/options.rb', line 2265

def facets
  @facets
end

#fieldsArray<String>



2260
2261
2262
# File 'lib/couchbase/options.rb', line 2260

def fields
  @fields
end

#highlight_fieldsArray<String>



2259
2260
2261
# File 'lib/couchbase/options.rb', line 2259

def highlight_fields
  @highlight_fields
end

#highlight_styleSymbol



2258
2259
2260
# File 'lib/couchbase/options.rb', line 2258

def highlight_style
  @highlight_style
end

#include_locationsBoolean



2262
2263
2264
# File 'lib/couchbase/options.rb', line 2262

def include_locations
  @include_locations
end

#limitInteger



2255
2256
2257
# File 'lib/couchbase/options.rb', line 2255

def limit
  @limit
end

#mutation_stateMutationState (readonly)

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.



2358
2359
2360
# File 'lib/couchbase/options.rb', line 2358

def mutation_state
  @mutation_state
end

#scan_consistencySymbol

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.



2362
2363
2364
# File 'lib/couchbase/options.rb', line 2362

def scan_consistency
  @scan_consistency
end

#skipInteger



2256
2257
2258
# File 'lib/couchbase/options.rb', line 2256

def skip
  @skip
end

#sortArray<String, Cluster::SearchSort>



2264
2265
2266
# File 'lib/couchbase/options.rb', line 2264

def sort
  @sort
end

#transcoderJsonTranscoder, #decode(String)



2266
2267
2268
# File 'lib/couchbase/options.rb', line 2266

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



2338
2339
2340
2341
# File 'lib/couchbase/options.rb', line 2338

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

#to_backend(show_request: nil) ⇒ 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.



2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
# File 'lib/couchbase/options.rb', line 2365

def to_backend(show_request: nil)
  {
    timeout: Utils::Time.extract_duration(@timeout),
    limit: @limit,
    skip: @skip,
    explain: @explain,
    disable_scoring: @disable_scoring,
    include_locations: @include_locations,
    collections: @collections,
    highlight_style: @highlight_style,
    highlight_fields: @highlight_fields,
    fields: @fields,
    sort: @sort&.map { |v| JSON.generate(v) },
    facets: @facets&.map { |(k, v)| [k, JSON.generate(v)] },
    scan_consistency: @scan_consistency,
    mutation_state: @mutation_state&.to_a,
    show_request: show_request,
  }
end