简体   繁体   English

django-haystack + Whoosh SearchQuerySet()。all()始终为None

[英]django-haystack + Whoosh SearchQuerySet().all() always None

I am using: 我在用:

django: 1.9.7 django:1.9.7
django-haystack: 2.5.0 django-haystack:2.5.0
whoosh: 2.7.4 哇:2.7.4

search_index.py search_index.py

class ProfileIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    last_name= indexes.CharField(model_attr='last_name')
    content_auto = indexes.EdgeNgramField(model_attr='first_name')
    def get_model(self):
        return User
    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()  

user_text.txt user_text.txt

{{ object.last_name }}

in the views.py i try: 在views.py中我尝试:
SearchQuerySet().count() => returns 0
SearchQuerySet().all() => returns None

I've read about some issues with the latest Whoosh implementation in django-haystack but i'm not sure if the problem is in my code 我已经阅读了django-haystack中最新的Whoosh实现的一些问题,但我不确定问题是否在我的代码中

Please see my answer here: 请在这里看到我的答案:

Django Haystack & Whoosh Search Working, But SearchQuerySet Return 0 Results Django Haystack&Whoosh搜索工作,但SearchQuerySet返回0结果

There is a bug in Django-Haystack with Woosh that means if you use an Ngram or EdgeNGram field SearchQuerySet().count() and SearchQuerySet().all().count() will always return 0 unless you specify a filter. Django-Haystack与Woosh有一个错误,这意味着如果你使用Ngram或EdgeNGram字段SearchQuerySet()。count()和SearchQuerySet()。all()。count()将始终返回0,除非你指定一个过滤器。

eg 例如

SearchQuerySet().all().count()
>> 0

SearchQuerySet().all().exclude(content='thisshouldnotmatchanything').count()
>> 14 [the total number of indexed objects]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM