from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
doc = {
\'author\': \'kimchy\',
\'text\': \'Elasticsearch: cool.
Note that one of the common reasons for timeouts when doing es.search (or es.index) is large query size. For example, in my case of a pretty large ES index size (> 3M documents), doing a search for a query with 30 words took around 2 seconds, while doing a search for a query with 400 words took over 18 seconds. So for a sufficiently large query even timeout=30 won't save you. An easy solution is to crop the query to the size that can be answered below the timeout.
Increasing timeout or doing retries on timeout will help you if the cause was in traffic, otherwise this might be your culprit.