簡體   English   中英

django-haystack + Whoosh SearchQuerySet()。all()始終為None

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

我在用:

django:1.9.7
django-haystack:2.5.0
哇:2.7.4

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

{{ object.last_name }}

在views.py中我嘗試:
SearchQuerySet().count() => returns 0
SearchQuerySet().all() => returns None

我已經閱讀了django-haystack中最新的Whoosh實現的一些問題,但我不確定問題是否在我的代碼中

請在這里看到我的答案:

Django Haystack&Whoosh搜索工作,但SearchQuerySet返回0結果

Django-Haystack與Woosh有一個錯誤,這意味着如果你使用Ngram或EdgeNGram字段SearchQuerySet()。count()和SearchQuerySet()。all()。count()將始終返回0,除非你指定一個過濾器。

例如

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