Class: Elasticsearch::DSL::Search::Queries::InnerHits
- Inherits:
-
Object
- Object
- Elasticsearch::DSL::Search::Queries::InnerHits
- Includes:
- BaseComponent
- Defined in:
- lib/elasticsearch/dsl/search/queries/inner_hits.rb
Overview
Wraps the ‘inner_hits` part of a search definition
Instance Method Summary collapse
-
#from(from) ⇒ Object
Specify the from setting on the inner_hits definition, the offset from where the first hit to fetch for each inner_hits in the returned regular search hits.
-
#initialize(name = nil, &block) ⇒ InnerHits
constructor
Initialize the inner_hits definition.
-
#size(size) ⇒ Object
Specify the size setting on the inner_hits definition, the maximum number of hits to return per inner_hits.
-
#sort(*args, &block) ⇒ Object
Specify the sorting on the inner_hits definition.
-
#to_hash ⇒ Hash
Convert the definition to a hash, to be used in a search request.
Methods included from BaseComponent
Constructor Details
#initialize(name = nil, &block) ⇒ InnerHits
Initialize the inner_hits definition.
38 39 40 41 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 38 def initialize(name=nil, &block) @value = name ? { name: name } : {} super end |
Instance Method Details
#from(from) ⇒ Object
Specify the from setting on the inner_hits definition, the offset from where the first hit to fetch for
each inner_hits in the returned regular search hits.
76 77 78 79 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 76 def from(from) @value[:from] = from self end |
#size(size) ⇒ Object
Specify the size setting on the inner_hits definition, the maximum number of hits to return per inner_hits.
By default the top three matching hits are returned.
57 58 59 60 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 57 def size(size) @value[:size] = size self end |
#sort(*args, &block) ⇒ Object
Specify the sorting on the inner_hits definition. By default the hits are sorted by the score.
98 99 100 101 102 103 104 105 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 98 def sort(*args, &block) if !args.empty? || block @sort = Sort.new(*args, &block) self else @sort end end |
#to_hash ⇒ Hash
Convert the definition to a hash, to be used in a search request.
123 124 125 126 127 128 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 123 def to_hash call @hash = @value @hash[:sort] = @sort.to_hash if @sort @hash end |