Hi everyone,
I have Product documents that have nested Attributes. Each Product document has a full set of nested Attributes, but I would like to control which Attributes get returned.
I thought I could use a QueryContainer that is a list of all Attributes that I would like to return in the aggregation, like this:
QueryContainer attDisplay = null;
foreach (ESAttribute attribute in category.Attributes)
attDisplay |= new TermQuery() { Field = "attributes.attributeId", Value = attribute.AttributeID };
But I'm not sure how to use it.
Here is my attribute aggregation which returns all Attributes for the Products. I am filtering the Product documents by categories and manufacturers here, but I want to be able to filter the nested "attributes" by the query above. I don't want to filter the parent Product documents, but filter the nested Attribute aggregation that gets returned. Does anyone know of a way to accomplish this?
Thanks!
.Aggregations(agg => agg
.Filter("att_agg", cf => cf
.Filter(f => f
.Bool(b => b
.Must(ms =>
ms.Nested(n => n.Path("categories").Query(q => q.Bool(b1 => b1.Must(m => catQuery || m.Strict(catQuery == null))))) &&
ms.Nested(n => n.Path("manufacturer").Query(q => q.Bool(b1 => b1.Must(m => manQuery || m.Strict(manQuery == null)))))
)
)
)
.Aggregations(a => a
.Nested("att_nest", n => n
.Path("attributes")
.Aggregations(a1 => a1.Terms("agg_attNames", f1 => f1.Field("attributes.idName").Size(5)
.Aggregations(a2 => a2.Terms("agg_attValues", f2 => f2.Field("attributes.attributeValue").Size(5))))
)
)
)
)
)