Class: Couchbase::Options::Search

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

Overview

Options for Cluster#search_query

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

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



1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
# File 'lib/couchbase/options.rb', line 1596

def initialize(limit: nil,
               skip: nil,
               explain: false,
               highlight_style: nil,
               highlight_fields: nil,
               fields: nil,
               mutation_state: nil,
               disable_scoring: false,
               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
  @sort = sort
  @facets = facets
  @transcoder = transcoder
  @scan_consistency = :not_bounded
  @mutation_state = mutation_state
  yield self if block_given?
end

Instance Attribute Details

#disable_scoringBoolean

Returns:

  • (Boolean)


1565
1566
1567
# File 'lib/couchbase/options.rb', line 1565

def disable_scoring
  @disable_scoring
end

#explainBoolean

Returns:

  • (Boolean)


1561
1562
1563
# File 'lib/couchbase/options.rb', line 1561

def explain
  @explain
end

#facetsHash<String => Cluster::SearchFacet>

Returns:



1567
1568
1569
# File 'lib/couchbase/options.rb', line 1567

def facets
  @facets
end

#fieldsArray<String>

Returns:

  • (Array<String>)


1564
1565
1566
# File 'lib/couchbase/options.rb', line 1564

def fields
  @fields
end

#highlight_fieldsArray<String>

Returns:

  • (Array<String>)


1563
1564
1565
# File 'lib/couchbase/options.rb', line 1563

def highlight_fields
  @highlight_fields
end

#highlight_styleSymbol

Returns:

  • (Symbol)


1562
1563
1564
# File 'lib/couchbase/options.rb', line 1562

def highlight_style
  @highlight_style
end

#limitInteger

Returns:

  • (Integer)


1559
1560
1561
# File 'lib/couchbase/options.rb', line 1559

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



1647
1648
1649
1650
# File 'lib/couchbase/options.rb', line 1647

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

#skipInteger

Returns:

  • (Integer)


1560
1561
1562
# File 'lib/couchbase/options.rb', line 1560

def skip
  @skip
end

#sortArray<String, Cluster::SearchSort>

Returns:



1566
1567
1568
# File 'lib/couchbase/options.rb', line 1566

def sort
  @sort
end

#transcoderJsonTranscoder, #decode(String)

Returns:



1568
1569
1570
# File 'lib/couchbase/options.rb', line 1568

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



1634
1635
1636
1637
# File 'lib/couchbase/options.rb', line 1634

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