本文介绍了干草堆查询集不包含任何元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Haystack进行搜索,返回的结果SearchQuerySet包含None元素:
I'm using Haystack for search, and the resulting SearchQuerySet returned contains None elements:
>> SearchQuerySet().models(Question, Document, Idea)
>> [<SearchResult: idea.idea (pk=3875)>, None, None, None]
运行rebuild_index没有帮助。如果我从第一行中删除.models()调用,问题就消失了。我可以从结果中过滤掉None元素,但是我想知道这是否是预期的行为吗?
Running rebuild_index doesn't help. If I remove the .models() call from the first line, the problem goes away. I could just filter out None elements from the results, but I wanted to know if this is intended behaviour?
我正在使用Django 1.4,Whoosh和Haystack 2.0.0 -beta
I am using Django 1.4, Whoosh, and Haystack 2.0.0-beta
推荐答案
当haystack索引中的记录中没有对应的记录时,我遇到了这个问题。
I had this problem when haystack index had records without corresponding records in DB.
这篇关于干草堆查询集不包含任何元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!