while running script in elastic search, I got 504 Gateway timeout error.
{
"query": {
"bool": {
"filter": {
"script": {
"script": " doc['creted_date'].date.getMonthOfYear() == 12 "
}
}
}
},
"aggs": {
"test": {
"date_histogram": {
"field": "creted_date",
"interval": "month",
"format": "MMM"
},
"aggs": {
"cost": {
"sum": {
"field": "cost"
}
}
}
}
}
}
Error result :
{
"statusCode": 504,
"error": "Gateway Time-out",
"message": "Client request timeout"
}
whenever I am running this script over index having small number of documents , it gives perfect output. but on index having large number of documents , it gives above error.
Can we manually set the timeout for request in elastic search ? or Is there any other solution for this problem ?
Try this for Elasticsearch 6.x.
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['created_on'].date.getMonthOfYear() == params.month",
"params": {
"month": 5
}
}
}
}
}
}
}