chewy
chewy copied to clipboard
aggregation that can be bound to a query or filter not working
I have the following orders_index
class OrdersIndex < Chewy::Index
settings analysis: {
analyzer: {
lower_keyword_autocomplete: {
tokenizer: 'keyword',
filter: ["lowercase"]
}
}
}
define_type Order.all.includes(:products) do
field :total, type: 'float'
field :total_items, type: 'long'
field :products do
field :name, analyzer: 'lower_keyword_autocomplete'
field :description, analyzer: 'lower_keyword_autocomplete'
field :price, type: 'float'
field :category, value: ->(product) { product.category.name }, analyzer: 'lower_keyword_autocomplete'
end
agg :avg_price do
{ avg: { field: 'products.price'} }
end
end
end
Following this, i am trying to evaluate an aggregate to compute average of price for query.
Upon firing rake chewy:reset, i am unable to find avg_price field created in my orders index.