使用 django-haystack 和 Spatial Solr 插件对多个位置进行半径搜索
我有一个 Person 模型,现在可以有多个办公室“位置”,每个位置都有自己的纬度/经度。
在只能添加 1 个办公室之前,我一直在使用我为 django-haystack 制作的一个叉子,它使用 JTeam 的 Spatial-solr-plugin 来进行半径搜索。请参阅 https://github.com/sidmitra/django-haystack
class PersonIndex(indexes.SearchIndex):
lat = indexes.FloatField()
lng = indexes.FloatField()
sqs.spatial(lat=lat, long=lng, radius=radius, unit=kwargs.get('unit'))
因为办公室数量不受限制,我无法在索引中使用单独的 lat/lng 字段。
我能想到的一种方法是索引“位置”模型。每个位置都是索引中的一个单独条目。因此解决了这个问题,但这意味着将人员索引中的所有字段复制到该位置索引。虽然这在短期内可能是一个不错的解决方案,但从长远来看可能会很混乱?
想知道是否有一种方法可以单独索引位置,然后根据指定半径内的地址过滤相关人员?
I have a Person model which now can have a number of office "locations", each with its own latitude/longitude.
Before one could add only 1 office, So i'd been using a fork I made for django-haystack that uses JTeam's spatial-solr-plugin to do radius search. See https://github.com/sidmitra/django-haystack
class PersonIndex(indexes.SearchIndex):
lat = indexes.FloatField()
lng = indexes.FloatField()
sqs.spatial(lat=lat, long=lng, radius=radius, unit=kwargs.get('unit'))
Since the number of offices are unlimited, i can't use separate lat/lng fields in the index.
One way i could think of was to index the "Location" model instead. Each location would be a seperate entry in the index. Thus solving this problem, but would mean replicating all of the fields from the Person index to this location index. Although this might be a decent solution in the short term, but would probably be untidy in the long run?
Wondering if there's a way to index locations separately and then filter related Person, based on the addresses that are within the specified radius?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论