Class: Elasticsearch::DSL::Search::Highlight
- Inherits:
-
Object
- Object
- Elasticsearch::DSL::Search::Highlight
- Includes:
- BaseComponent
- Defined in:
- lib/elasticsearch/dsl/search/highlight.rb
Overview
Wraps the ‘highlight` part of a search definition
Instance Method Summary collapse
-
#encoder(value) ⇒ Object
(also: #encoder=)
Specify the ‘encoder` option for highlighting.
-
#field(name, options = {}) ⇒ Object
Specify a single field to highlight.
-
#fields(value_or_name) ⇒ Object
Specify the fields to highlight.
-
#initialize(*args, &block) ⇒ Highlight
constructor
A new instance of Highlight.
-
#post_tags(*value) ⇒ Object
(also: #post_tags=)
Specify the closing tags for the highlighted snippets.
-
#pre_tags(*value) ⇒ Object
(also: #pre_tags=)
Specify the opening tags for the highlighted snippets.
-
#tags_schema(value) ⇒ Object
(also: #tags_schema=)
Specify the ‘tags_schema` option for highlighting.
-
#to_hash ⇒ Hash
Convert the definition to a Hash.
Methods included from BaseComponent
Constructor Details
#initialize(*args, &block) ⇒ Highlight
Returns a new instance of Highlight.
12 13 14 15 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 12 def initialize(*args, &block) @value = args.pop || {} super end |
Instance Method Details
#encoder(value) ⇒ Object Also known as: encoder=
Specify the ‘encoder` option for highlighting
70 71 72 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 70 def encoder(value) @value[:encoder] = value end |
#field(name, options = {}) ⇒ Object
Specify a single field to highlight
52 53 54 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 52 def field(name, ={}) (@value[:fields] ||= {}).update name.to_sym => end |
#fields(value_or_name) ⇒ Object
Specify the fields to highlight
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 28 def fields(value_or_name) value = case value_or_name when Hash value_or_name when Array value_or_name.reduce({}) { |sum, item| sum.update item.to_sym => {}; sum } else end (@value[:fields] ||= {}).update value self end |
#post_tags(*value) ⇒ Object Also known as:
Specify the closing tags for the highlighted snippets
64 65 66 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 64 def (*value) @value[:post_tags] = value.flatten end |
#pre_tags(*value) ⇒ Object Also known as:
Specify the opening tags for the highlighted snippets
58 59 60 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 58 def (*value) @value[:pre_tags] = value.flatten end |
#tags_schema(value) ⇒ Object Also known as:
Specify the ‘tags_schema` option for highlighting
76 77 78 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 76 def (value) @value[:tags_schema] = value end |
#to_hash ⇒ Hash
Convert the definition to a Hash
84 85 86 87 88 |
# File 'lib/elasticsearch/dsl/search/highlight.rb', line 84 def to_hash call @hash = @value @hash end |