Class: Elasticsearch::DSL::Search::Collapse
- Inherits:
-
Object
- Object
- Elasticsearch::DSL::Search::Collapse
- Includes:
- BaseComponent
- Defined in:
- lib/elasticsearch/dsl/search/collapse.rb
Overview
Wraps the ‘collapse` part of a search definition
Instance Method Summary collapse
-
#initialize(field, &block) ⇒ Collapse
constructor
Initialize the field collapse definition.
-
#inner_hits(name, &block) ⇒ Object
Create an inner_hits definition.
-
#max_concurrent_group_searches(max) ⇒ Object
Specify the max_concurrent_group_searches setting on the collapse definition.
-
#to_hash ⇒ Hash
Convert the definition to a hash, to be used in a search request.
Methods included from BaseComponent
Constructor Details
#initialize(field, &block) ⇒ Collapse
Initialize the field collapse definition.
35 36 37 38 |
# File 'lib/elasticsearch/dsl/search/collapse.rb', line 35 def initialize(field, &block) @hash = { field: field } @block = block end |
Instance Method Details
#inner_hits(name, &block) ⇒ Object
Create an inner_hits definition.
57 58 59 60 |
# File 'lib/elasticsearch/dsl/search/collapse.rb', line 57 def inner_hits(name, &block) @inner_hits = Queries::InnerHits.new(name, &block) self end |
#max_concurrent_group_searches(max) ⇒ Object
Specify the max_concurrent_group_searches setting on the collapse definition.
72 73 74 75 |
# File 'lib/elasticsearch/dsl/search/collapse.rb', line 72 def max_concurrent_group_searches(max) @hash[:max_concurrent_group_searches] = max self end |
#to_hash ⇒ Hash
Convert the definition to a hash, to be used in a search request.
87 88 89 90 91 |
# File 'lib/elasticsearch/dsl/search/collapse.rb', line 87 def to_hash call @hash[:inner_hits] = @inner_hits.to_hash if @inner_hits @hash end |