【发布时间】:2015-02-04 20:23:07
【问题描述】:
我有一个带有 GeoField 和 NumberField 的文档,如下所示:
document = search.Document(doc_id=str(self.id),
fields=[search.GeoField(name='loc',value=search.GeoPoint(20.0, 30.0)),
search.NumberField(name='maxradius', value=10)])
search.Index(name='Professional').put(document)
当我查询时:
query = "distance(loc, geopoint(20.0, 30.0)) < 10"
我得到正确的结果 但是当我查询时:
query = "distance(loc, geopoint(20.0, 30.0)) < maxradius"
我收到RuntimeError: ValueError('could not convert string to float: maxradius',)
发生了什么,有什么想法吗?
【问题讨论】:
-
我怀疑这不能在当前的 AppEngine 搜索 API 中完成。有关文档,请参阅cloud.google.com/appengine/docs/python/search/query_strings,尽管它没有明确解决这个问题。我认为您应该使用较大的固定最大半径(例如 100km / 100000m),然后将距离作为 QueryOptions 中指定的字段表达式返回,然后您必须使用每个单独的最大半径手动过滤列表。 cloud.google.com/appengine/docs/python/search/…
标签: python google-app-engine google-search-api