Class: Blocktrain::Aggregations::TermsAggregation
Instance Method Summary
collapse
#body
Methods inherited from Query
#address_query, #body, #build_query, #filtered_filter, #filtered_query, #hits, #parse_datetime
Constructor Details
Returns a new instance of TermsAggregation.
5
6
7
8
9
|
# File 'lib/blocktrain/aggregations/terms_aggregation.rb', line 5
def initialize(options = {})
@term = options.fetch(:term, nil)
raise ArgumentError.new("TermAggregation requires a term: argument") unless @term
super
end
|
Instance Method Details
#aggs ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/blocktrain/aggregations/terms_aggregation.rb', line 19
def aggs
{
langs: {
terms: {
field: @term,
size: 0
}
}
}
end
|
#query ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/blocktrain/aggregations/terms_aggregation.rb', line 11
def query
{
filtered: {
filter: filtered_filter
}
}
end
|
#results ⇒ Object
30
31
32
|
# File 'lib/blocktrain/aggregations/terms_aggregation.rb', line 30
def results
result['aggregations']['langs']['buckets']
end
|