如何检索 Haystack SearchQuery 参数
我正在寻找一种方法来序列化 Haystack 搜索查询(而不是查询结果),以便稍后可以重建它。有没有一种方法可以做到这一点,而不必从 request
对象中拦截参数?
对于上下文,我希望用户能够订阅特定搜索的结果,包括随着时间的推移可能弹出的任何新结果。
编辑:
我决定使用以下方式存储搜索:
filter = queryset.query.query_filter
然后使用以下方式将其加载回来:
SearchQuerySet().raw_search(filter)
尽管我怀疑这会将我与我现在使用的任何特定搜索后端联系起来。这是真的吗?有更好的办法吗?
I am looking for a way to serialize a Haystack search query (not the query results) so that I can reconstruct it later. Is there a way to do this without having to intercept the parameters from off of the request
object?
For context, I want users to be able to subscribe to the results of a particular search, including any new results that may pop up over time.
Edit:
I settled on storing the search with:
filter = queryset.query.query_filter
and then loading this back in using:
SearchQuerySet().raw_search(filter)
Though I suspect this will tie me to whichever particular search back-end I'm using now. Is this true? Is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您应该在 request.GET 中包含查询。然后使用该查询构建 RSS Feed 应该相当容易。
You should have the query in your request.GET. Then it should be fairly easy to construct a RSS Feed using that query.