简体   繁体   中英

Terms failed to parse field size Error when aggregating with two terms in elastic search

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
        }
    }
}
})

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM