如何从Elasticsearch DSL中的聚合中获取价值

时间:2018-06-22 06:56:32

标签: python django elasticsearch

我开始对Elasticsearch dsl有所了解,并遇到了问题。我无法从聚合中获得价值。我正在使用metric方法,但是当我想从“ new_distance”获取值时出现错误。怎么了?

    res = MyIndex.search()\
      .filter('geo_distance', distance='1km', location={"lat":"32.895", "lon":"21.115"})\
      .aggs.metric('new_distance', 'max', field='point')
    result = res.to_queryset()
    print(result[0].new_distance)

错误

'Comments' object has no attribute 'new_distance'

0 个答案:

没有答案