class Elasticsearch::DSL::Search::Collapse
Wraps the `collapse` part of a search definition
@see www.elastic.co/guide/en/elasticsearch/reference/current/search-request-collapse.html
@since 0.1.9
Public Class Methods
new(field, &block)
click to toggle source
Initialize the field collapse definition.
@param field [ String, Symbol ] The name of the field.
@since 0.1.9
# File lib/elasticsearch/dsl/search/collapse.rb, line 35 def initialize(field, &block) @hash = { field: field } @block = block end
Public Instance Methods
inner_hits(name, &block)
click to toggle source
Create an inner_hits
definition.
@example
collapse :user inner_hits 'last_tweet' do size 10 from 5 sort do by :date, order: 'desc' by :likes, order: 'asc' end end end
@return self
@since 0.1.9
# 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)
click to toggle source
Specify the max_concurrent_group_searches
setting on the collapse definition.
@example
collapse :user max_concurrent_group_searches 4 end
@return self.
@since 0.1.9
# 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()
click to toggle source
Convert the definition to a hash, to be used in a search request.
@example
definition = collapse :user max_concurrent_group_searches 4 end
@return [ Hash ] The collapse clause as a hash.
@since 0.1.9
# 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