我希望计算一些索引产品数据的值计数聚合,但我似乎在ValueCountAgg
构造函数中得到了一些错误的参数。
此类索引数据的示例如下:
{
"_index": "test-index",
"_type": "product_product",
"_id": "1",
"_score": 1,
"_source": {
"code": "SomeProductCode1",
"list_price": 10,
"description": null,
"displayed_on_eshop": "true",
"active": "true",
"tree_nodes": [],
"id": 1,
"category": {},
"name": "This is Product",
"price_lists": [
{
"price": 10,
"id": 1
},
{
"price": 10,
"id": 2
}
],
"attributes": {
"color": "blue",
"attrib": "something",
"size": "L"
},
"type": "goods"
}
}
我正在计算聚合如下-:
for attribute in filterable_attributes:
count = ValueCountAgg(
name='count_'+attribute, field='attributes.'+attribute
)
query.agg.add(count)
包裹在对象query
中的对象在哪里。是属性名称的列表,例如颜色和大小。~pyes.query.Query
~pyes.query.Search
filterable_attributes
我也尝试过设置field=attribute
,但似乎没有什么区别。我在进行搜索时获得的结果集具有以下aggs
属性-:
{'count_size': {'value': 0}, 'count_color': {'value': 0}}
wheresize
和color
在attributes
字典中被索引,如上所示。这些显然是错误的结果,我认为是因为我没有field
正确设置。
我哪里错了?