Reputation: 176
I have the following two aggregations in Rails using searchkick gem. When I used any of them separately, it works like a charm. But I want to "merge" them together and cannot figure out how to do it :(.
Aggregation 1:
aggs: { price_vat: { ranges: [{to: 5}, {from: 5, to: 10}, {from: 10}] } }
Aggregation 2:
aggs: ['property_options.property_id', 'property_options.id', 'property_options.value_cs', 'property_options.value_en', 'manufacturer_id']
Is there any expert on this who knows how to do it? Really appreciated. Thank you and have a good weekend, Miro.
Upvotes: 3
Views: 947
Reputation: 56
you have to the define the "aggs" as hashes. Then you can easily merge them together.
example:
range_aggregations = { price_vat: { ranges: [{to: 5}, {from: 5, to: 10}, {from: 10}] } }
base_aggregations = {
property_options.property_id: {},
property_options.id: {}
}
Now merge them togehter:
range_aggregations.merge(base_aggregations)
Upvotes: 3