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.
25 26 27 28 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 25 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.
63 64 65 66 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 63 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.
44 45 46 47 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 44 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.
85 86 87 88 89 90 91 92 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 85 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.
110 111 112 113 114 115 |
# File 'lib/elasticsearch/dsl/search/queries/inner_hits.rb', line 110 def to_hash call @hash = @value @hash[:sort] = @sort.to_hash if @sort @hash end |