I'm trying to query elastic search for all the logs between two milliseconds timestamps.
When querying Elasticsearch directly via:
curl -XPOST <ElasticSearch> ' -d ' {"query" : { "bool" : { "must" : { "range" : { "received_at" : { "gte" : 1310325395701, "lte" : 1468933745000 } } } } } }'
I obtain the desired result. However, the following query from a Python script returns 0 hits:
res = es.search(index="syslog-*", body={ "query" : { "bool" : { "must" : { "range" : { "received_at" : { "gte" : 1310325395701, "lte" : 1468933745000 } } } } } }, size=6000)
I've also tried this one:
res = es.search(index="syslog-*", body= { "query" : { "range" : { "received_at" : { "gte" : 1310325395701, "lte" : 1468933745000 } } } }, size=6000)
But exactly the same thing happens. Other kinds of queries from the python script do return hits:
res = es.search(index="syslog-*", body={"query": {"match_all": {}}}, size=6000)
Where:
from elasticsearch import RequestsHttpConnection
class MyConnection(RequestsHttpConnection):
def __init__(*args, **kwargs):
proxies = kwargs.pop('proxies', {})
super(MyConnection, self).__init__(*args, **kwargs)
self.session.proxies = proxies
es = Elasticsearch([es_url], connection_class=MyConnection, proxies = {'https': 'http://user:pw@proxy.org:port'})
What am I doing wrong?