Reputation: 81
i am using aggregations and aggregation bucket accept one key value as default then i research and find it
"aggs" : {
"my_buckets": {
"composite" : {
"sources" : [
{ "category_pk": { "terms": { "field": "category.pk"} } },
{ "category_name": { "terms": {"field": "category.name" } } }
]
}
}
}
}
Above code result two keys , and _doc_count but i can't apply for elasticsearch-dsl Someone help me
Upvotes: 4
Views: 2279
Reputation: 81
I solved the problem,When We are using Composite
s = ProductDocument.search()
brand_name = A('terms', field='brand.name')
brand_pk = A('terms', field='brand.id')
brand_key_aggs = [
{'brand_pk': brand_pk},
{'brand_name': brand_name}
]
s.aggs.bucket('brand_terms', "composite", sources=brand_key_aggs)
Example Result
{
'key':{
'brand_pk':869,
'brand_name':'Uni Baby'
},
'doc_count':2
},
Upvotes: 4