或者可以将django的干草堆中的距离过滤器与距离过滤器结合使用吗?
我一直在使用“或子”内的常规django查询过滤器使用距离过滤器:
# either it's within the preset distance of the location
# OR it's not an in-person event
self.filter(Q(location__distance_lt=(geometry, LOCATION_WITHIN_D)) | ~Q(type=Event.IN_PERSON))
我想使用SQ进行类似的过滤,作为Haystack查询的一部分,使用SQ:
queryset = queryset.filter(SQ(location__distance_lt=(geometry, LOCATION_WITHIN_D)) | ~SQ(type=Event.IN_PERSON))
但是我会收回错误:并非所有参数在字符串格式期间转换
- ,这仅发生在dange_lt查询部分中,而不是〜sq(type ..)
我能够通过我的haystack搜索查询应用距离过滤使用
queryset = queryset.dwithin('location', geometry, LOCATION_WITHIN_D)`
,但我希望能够在此款中具有“或”条件。
原始查询甚至可以吗?我如何为Elasticsearch构建这样的原始查询,并仍将其作为Haystack查询的一部分执行?
I've been using a distance filter using regular django query filters within an OR-clause:
# either it's within the preset distance of the location
# OR it's not an in-person event
self.filter(Q(location__distance_lt=(geometry, LOCATION_WITHIN_D)) | ~Q(type=Event.IN_PERSON))
I want to do a similar filtering as part of a haystack query, using SQ:
queryset = queryset.filter(SQ(location__distance_lt=(geometry, LOCATION_WITHIN_D)) | ~SQ(type=Event.IN_PERSON))
but instead I get back the error: not all arguments converted during string formatting
- and that only happens with the distance_lt query part, not the ~SQ(type..)
I'm able to apply the distance filtering with my haystack search query by using
queryset = queryset.dwithin('location', geometry, LOCATION_WITHIN_D)`
but I want to be able to have that 'or' condition in this sub-clause.
Is this even possible with raw querying? How can I construct such a raw query for ElasticSearch and still execute it as part of my haystack query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以针对Elasticsearch连接执行搜索。
You can perform the search against the Elasticsearch connection.