我有一个Elasticsearch范围查询,我想将其转换为elasticsearch-dsl:
{"range":
{"@timestamp":
{"gte": 1570258800000,
"lte": 1571036400000,
"format": "epoch_millis"
}
}
}
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
client = Elasticsearch(<connection_details>)
s = Search(using=client, index="my-index") \
.query("???")
答案 0 :(得分:1)
尝试一下:
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
client = Elasticsearch(<connection_details>)
s = Search(using=client, index="my-index") \
.filter('range' , **{'@timestamp': {'gte': 1570258800000 , 'lt': 1571036400000, 'format' : 'epoch_millis'}})
答案 1 :(得分:0)
s = s.query('range', **{'@timestamp': {'gte': ...}})
希望这会有所帮助