如何在 haystack-solr 中获取搜索时间
如何在后端使用 solr 获取在 haystack 中搜索查询所需的时间?我想获取这个时间并将其显示在我的模板上。与谷歌显示的类似。
How can I get the time it takes for a searching a query in haystack using solr
at the backend? I want to get this time and display it on my template. Something similar to what google shows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过尽我所能的挖掘后,目前无法使用 Haystack 从 SOLR 访问查询时间(QTime)。
pysolr 对象附加了 QTime。
https://github.com/toastdriven/pysolr/blob/master/pysolr .py#L265
然而,Haystack 并未从对象中提取此信息。
https://github.com/toastdriven/django -haystack/blob/master/haystack/backends/solr_backend.py#L313
在 _process_results() 中 raw_results 是pysolr 对象但是您可以看到 qtime 没有返回。
https://github.com/toastdriven/django -haystack/blob/master/haystack/backends/solr_backend.py#L382
After some digging as best as I can work out it is not currently possible to access the query time (QTime) from SOLR using Haystack.
The pysolr object has the QTime attached to it.
https://github.com/toastdriven/pysolr/blob/master/pysolr.py#L265
However this information is not extracted from the object by Haystack.
https://github.com/toastdriven/django-haystack/blob/master/haystack/backends/solr_backend.py#L313
In _process_results() raw_results is a pysolr object however you can see that qtime is not returned.
https://github.com/toastdriven/django-haystack/blob/master/haystack/backends/solr_backend.py#L382