Class: Couchbase::Options::Search

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/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, scoring: nil, 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) —

    DEPRECATED: Use scoring with SearchScoring.none instead. If set to true, the server will not perform any scoring on the hits.

  • scoring (SearchScoring, nil) (defaults to: nil) —

    specifies the scoring mode used for the request. For a hybrid search (a traditional FTS query combined with one or more vector queries) a fusion strategy controls how the FTS and vector result sets are merged into a single ranked list. Must not be used together with disable_scoring.

  • 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 (Symbol, nil) (defaults to: nil) —

    ignored by this operation

  • 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:



2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
# File 'lib/couchbase/options.rb', line 2472

def initialize(limit: nil,
               skip: nil,
               explain: false,
               highlight_style: nil,
               highlight_fields: nil,
               fields: nil,
               mutation_state: nil,
               disable_scoring: false,
               scoring: nil,
               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
  @scoring = 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

#collections ⇒ Array<String>?

Returns:

  • (Array<String>, nil)


2434
2435
2436
# File 'lib/couchbase/options.rb', line 2434

def collections
  @collections
end

#disable_scoring ⇒ Boolean

Deprecated.

Use scoring with SearchScoring.none instead

Returns:

  • (Boolean)


2430
2431
2432
# File 'lib/couchbase/options.rb', line 2430

def disable_scoring
  @disable_scoring
end

#explain ⇒ Boolean

Returns:

  • (Boolean)


2423
2424
2425
# File 'lib/couchbase/options.rb', line 2423

def explain
  @explain
end

#facets ⇒ Hash<String => Cluster::SearchFacet>

Returns:



2436
2437
2438
# File 'lib/couchbase/options.rb', line 2436

def facets
  @facets
end

#fields ⇒ Array<String>

Returns:

  • (Array<String>)


2426
2427
2428
# File 'lib/couchbase/options.rb', line 2426

def fields
  @fields
end

#highlight_fields ⇒ Array<String>

Returns:

  • (Array<String>)


2425
2426
2427
# File 'lib/couchbase/options.rb', line 2425

def highlight_fields
  @highlight_fields
end

#highlight_style ⇒ Symbol

Returns:

  • (Symbol)


2424
2425
2426
# File 'lib/couchbase/options.rb', line 2424

def highlight_style
  @highlight_style
end

#include_locations ⇒ Boolean

Returns:

  • (Boolean)


2433
2434
2435
# File 'lib/couchbase/options.rb', line 2433

def include_locations
  @include_locations
end

#limit ⇒ Integer

Returns:

  • (Integer)


2421
2422
2423
# File 'lib/couchbase/options.rb', line 2421

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



2529
2530
2531
2532
# File 'lib/couchbase/options.rb', line 2529

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

#scoring ⇒ SearchScoring?

Returns:



2432
2433
2434
# File 'lib/couchbase/options.rb', line 2432

def scoring
  @scoring
end

#skip ⇒ Integer

Returns:

  • (Integer)


2422
2423
2424
# File 'lib/couchbase/options.rb', line 2422

def skip
  @skip
end

#sort ⇒ Array<String, Cluster::SearchSort>

Returns:



2435
2436
2437
# File 'lib/couchbase/options.rb', line 2435

def sort
  @sort
end

#transcoder ⇒ JsonTranscoder, #decode(String)

Returns:



2437
2438
2439
# File 'lib/couchbase/options.rb', line 2437

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



2516
2517
2518
2519
# File 'lib/couchbase/options.rb', line 2516

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