【发布时间】:2017-09-22 05:20:55
【问题描述】:
目前我有以下映射:
array(
'index' => 'my_index',
'body' => array(
'mappings' => array(
'products' => array(
'_source' => array('enabled' => false),
'properties' => array(
'id' => array('type' => 'integer'),
'active' => array('type' => 'boolean'),
'specs' => array(
'type' => 'nested',
'properties' => array(
'id' => array('type' => 'integer'),
'value' => array('type' => 'text'),
'visible' => array('type' => 'boolean')
)
)
)
)
)
)
);
我想查询产品。 并让 ElasticSearch 返回聚合的规范。但是对于每个 specs.id 都有一个包含所有值的存储桶。 并且仅当可见为真时。
"aggregations": {
"specs_2": {
"buckets": [
{
"key": "Yes",
"doc_count": 90
},
{
"key": "No",
"doc_count": 80
},
]
},
"specs_4": {
"buckets": [
{
"key": "Yes",
"doc_count": 190
},
{
"key": "No",
"doc_count": 180
},
]
}
}
不知道数据集中的规范 ID。
这可能吗?
【问题讨论】:
标签: elasticsearch mapping aggregation bucket