Reputation: 505
My code is self explanatory so won't provide additional details
es = Elasticsearch(['http://localhost:9200'])
e1={
"first_name":"nitin",
"last_name":"panwar",
"age": 27,
"about": "Love to play cricket",
"interests": ['sports','music'],
"timeout":100,
#"request_timeout":100 gives same error
}
res = es.index(index="test", doc_type="employee", id=1, body=e1)
I've read most posts about this error however all they talk about is to increase timeout which does not work for me.
This is the error:
ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=10))
Upvotes: 0
Views: 665
Reputation: 1979
You are trying to set timeout inside the body. You are supposed to initialize the elasticsearch client with the timeout param or depending on the client library there might be a request parameter for individual requests.
Param body depending on the context is usually the actual search query or data document (your case). Giving timeout in the body will make elasticsearch treat is as data to be indexed as document in your case.
Upvotes: 1