Elasticsearch条件query 发表于 2019-06-25 | 分类于 数据库 , Elasticsearch | 按照时间升序降序query1234567891011121314151617181920212223242526def query_byid(self, id, size, reverse_order=False): if reverse_order == True: _order = 'desc' else: _order = 'asc' dsl = { "query": { "bool":{ "must": [ {"match":{"id":id}}, ], } }, "sort": [ { "service.data.time" : {"order" : _order}}, "_score" ], "_source": [ "service.data", "deviceId" ], "size":size, } raw_data = self.query(dsl) raw_list = raw_data["hits"]["hits"] return raw_list