Reputation:
I want to aggregate on two terms, user and event and I want to fetch count of each event per user.
I have tried following code. But I am getting the error message in second last line that:
RequestError: TransportError(400, 'parsing_exception', '[terms] failed to parse field [size]')
Can you tell me how to solve this.
es.search(index=['ind'],doc_type=['axis'],body={
"query": {
"bool": {
"must": [
{
"range": {
"time": {
"gt": "10"
}
}
}
]
}
},
"from": 0,
"size": 0,
"aggregations": {
"user": {
"aggregations": {
"event": {
"aggregations": {
"COUNT(event)": {
"value_count": {
"field": "event"
}
}
},
"terms": {
"field": "event",
"size": 0
}
}
},
"terms": {
"field": "user",
"size": 200
}
}
}
})
Upvotes: 5
Views: 4216
Reputation: 887
The only problem with your query is in your aggregation size that is set to '0'
As mentioned in the comments. There is no point in doing an aggregation at zero sizes and thus elastic search throws the error
[size] must be greater than 0. Found [0] in [event]
Along with the above error you have mentioned
Hope this helps
Upvotes: 6