elasticsearch.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:django-haystack-elasticsearch 作者: CraveFood 项目源码 文件源码
def _build_search_filters_dwithin(self, dwithin):
        lng, lat = dwithin['point'].get_coords()
        # NB: the 1.0.0 release of elasticsearch introduce an
        #     incompatible change on the distance filter formating
        if elasticsearch.VERSION >= (1, 0, 0):
            distance = "%(dist).6f%(unit)s" % {
                'dist': dwithin['distance'].km,
                'unit': "km"
            }
        else:
            distance = dwithin['distance'].km
        dwithin_filter = {
            "geo_distance": {
                "distance": distance,
                dwithin['field']: {
                    "lat": lat,
                    "lon": lng
                }
            }
        }
        return dwithin_filter
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号