# Elasticsearch query timeout

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-timeout/245579>\
**Category:** Elasticsearch\
**Created:** [August 19, 2020, 10:05am UTC](https://discuss.elastic.co/t/elasticsearch-query-timeout/245579 "2020-08-19T10:05:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ubazu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ubazu/32/1417_2.png) [@ubazu](https://discuss.elastic.co/u/ubazu)\
**Post date:** [August 19, 2020, 10:05am UTC](https://discuss.elastic.co/t/elasticsearch-query-timeout/245579/1 "2020-08-19T10:05:17Z")

</div>

I am running an ES node on a 8 cores/16G RAM Qbox server.  
I am doing some indexing and search operations. indexing(max 5/second), search(max 14/second). My index has around 2M records and 1.2G of data. Search query takes around 300ms median.  
I am puzzled on why the server can not handle even such a low traffic.

Bellow is my mapping and the query I am sending:  
Mapping:

```auto
{
"orders_prod-1586935194034930": {
    "mappings": {
    "_doc": {
        "dynamic": "true",
        "properties": {
        "address_id": {
            "type": "long"
        },
        "card_4_digits": {
            "type": "keyword"
        },
        "card_type": {
            "type": "keyword"
        },
        "channel_id": {
            "type": "integer"
        },
        "created_at": {
            "type": "date",
            "format": "strict_date_hour_minute_second"
        },
        "customer_email": {
            "type": "keyword"
        },
        "customer_name": {
            "type": "keyword"
        },
        "customer_name_text": {
            "type": "text"
        },
        "customer_phone": {
            "type": "keyword"
        },
        "delivery_address": {
            "type": "keyword"
        },
        "favorite": {
            "type": "boolean"
        },
        "has_promo_discount": {
            "type": "boolean"
        },
        "id": {
            "type": "long"
        },
        "ivr_code": {
            "type": "keyword"
        },
        "order_at": {
            "type": "date",
            "format": "strict_date_hour_minute_second"
        },
        "order_type": {
            "type": "keyword"
        },
        "payment_type": {
            "type": "keyword"
        },
        "placed_at": {
            "type": "date",
            "format": "strict_date_hour_minute_second"
        },
        "restaurant_id": {
            "type": "integer"
        },
        "short_uuid": {
            "type": "keyword"
        },
        "state": {
            "type": "keyword"
        },
        "subtotal": {
            "type": "integer"
        },
        "total": {
            "type": "integer"
        },
        "updated_at": {
            "type": "date",
            "format": "strict_date_hour_minute_second"
        },
        "user_id": {
            "type": "integer"
        },
        "uuid": {
            "type": "keyword"
        },
        "workflow_color": {
            "type": "keyword"
        },
        "workflow_node_id": {
            "type": "keyword"
        },
        "workflow_node_name": {
            "type": "keyword"
        },
        "workflow_tag": {
            "type": "keyword"
        }
        }
    }
    }
}
}

```

The query:

```auto
{
"from":0,
"size":20,
"query":{
    "bool":{
        "must":[
            {
            "bool":{
                "should":[
                    {
                        "term":{
                        "user_id":{
                            "value":308612,
                            "boost":1.0
                        }
                        }
                    },
                    {
                        "term":{
                        "restaurant_id":{
                            "value":8898,
                            "boost":1.0
                        }
                        }
                    },
                    {
                        "term":{
                        "restaurant_id":{
                            "value":4164,
                            "boost":1.0
                        }
                        }
                    },
                    {
                        "term":{
                        "restaurant_id":{
                            "value":4679,
                            "boost":1.0
                        }
                        }
                    }
                ],
                "adjust_pure_negative":true,
                "minimum_should_match":"1",
                "boost":1.0
            }
            }
        ],
        "must_not":[
            {
            "term":{
                "state":{
                    "value":"created",
                    "boost":1.0
                }
            }
            }
        ],
        "should":[
            {
            "bool":{
                "should":[
                    {
                        "term":{
                        "state":{
                            "value":"executing",
                            "boost":1.0
                        }
                        }
                    },
                    {
                        "term":{
                        "state":{
                            "value":"missed",
                            "boost":1.0
                        }
                        }
                    }
                ],
                "adjust_pure_negative":true,
                "minimum_should_match":"1",
                "boost":1.0
            }
            }
        ],
        "adjust_pure_negative":true,
        "minimum_should_match":"1",
        "boost":1.0
    }
},
"_source":{
    "includes":[
        "short_uuid",
        "uuid",
        "state",
        "restaurant_id",
        "channel_id",
        "customer_name_text",
        "total",
        "payment_type",
        "card_type",
        "order_at"
    ],
    "excludes":[

    ]
},
"sort":[
    {
        "order_at":{
            "order":"asc"
        }
    },
    {
        "created_at":{
            "order":"desc"
        }
    }
]
}

```

Is there something I can do? maybe the query is not optimum at all. I would really need some hints.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 16, 2020, 10:05am UTC](https://discuss.elastic.co/t/elasticsearch-query-timeout/245579/2 "2020-09-16T10:05:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
