no result are found - haystack django whoosh

半城伤御伤魂 提交于 2019-12-11 04:03:38

问题


I have a huge problem!

I am using haystack and whoosh and django. I am sure I've done everything that is required to be done to make it works according to the documentation.

BUT!!!! results of searching are: "no results found" all the time. But if symbols I put into the form are spaces, every objects I've indexed are printed

Details:

In my search_indexes.py I have:

from haystack.indexes import *
from haystack import site
from aias.models import Uspd

class UspdIndex(SearchIndex):
    text   = CharField(document=True, use_template=True)
    serial = CharField(model_attr = 'serial')
    type_id = IntegerField(model_attr = 'type_id')
    name   = CharField(model_attr = 'name')

    def get_queryset(self):
        return Uspd.objects.all()                                                                                       
site.register(Uspd, UspdIndex)

I've created template in folder folder_where_I_have_templates/search/indexes/name_of_my_applcation and printed

{{ object.type_id }}
{{ object.name }}
{{ object.serial }}

there.

By the way I did

>>> from haystack.query import SearchQuerySet
>>> sqs = SearchQuerySet().all()
>>> sqs.count()

And result was 0 What the hell is going on????

Help me please!


回答1:


You haven't mentioned what the search document is called. It should be: uspd_text.txt

The doco said:

You’ll need to create a new template inside your template directory called search/indexes/myapp/note_text.txt and place the following inside



来源:https://stackoverflow.com/questions/4972234/no-result-are-found-haystack-django-whoosh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!