Hi,
I have product documents that have nested categories, as shown in the json below. When I aggregate categories, I would only like to aggregate the ones in the current category tree. For example, if I was currently in category 294, I would like it to aggregate Category1, but ignore Category2. My code below aggregates all categories in the category node. Any idea how I would filter what the aggregation is analyzing?
Thanks!
.Aggregations(a => a
.Nested("cat_nest", n => n
.Path("categories")
.Aggregations(a1 => a1.Terms("agg_categories", t => t.Field("categories.idName")))
)
)
{
"_index": "myindex",
"_type": "product",
"_id": "7308",
"_version": 1,
"found": true,
"_source": {
"manufacturerId": 260,
"categories": [
{
"id": 294,
"parentCategoryId": 2794,
"name": "Category1",
"idName": "294|Category1",
"categoryPath": "/1/2794/294"
},
{
"id": 1710,
"parentCategoryId": 63,
"name": "Category2",
"idName": "1710|Category2",
"categoryPath": "/63/1710"
}
],
"categoryPaths": [ "/1/2794/294", "/63/1710" ],
"id": 7308,
"name": "Product Name",
"sku": "340002"
}
}