Cadilac
Cadilac

Reputation: 1100

Django-haystack with whoosh

I am getting SearchBackendError at /forum/search/ No fields were found in any search_indexes. Please correct this before attempting to search.

with search_indexes placed in djangobb app root directory:

from haystack.indexes import *
from haystack import site

import djangobb_forum.models as models

class PostIndex(RealTimeSearchIndex):
    text = CharField(document=True, use_template=True)
    author = CharField(model_attr='user')
    created = DateTimeField(model_attr='created')
    topic = CharField(model_attr='topic')
    category = CharField(model_attr='topic__forum__category__name')
    forum = IntegerField(model_attr='topic__forum__pk')

site.register(models.Post, PostIndex)

settings.py

# Haystack settings 

HAYSTACK_SITECONF = 'search_sites'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_ROOT, 'djangobb_index')

also i havae haystack and whoosh in my installed apps.
In python interpreter:

>>> import haystack
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.../lib/python2.7/django_haystack-1.2.5-py2.5.egg/haystack/__init__.py", line 26, in <module>
    raise ImproperlyConfigured("You must define the HAYSTACK_SITECONF setting before using the search framework.")
django.core.exceptions.ImproperlyConfigured: You must define the HAYSTACK_SITECONF setting before using the search framework.

Has someone has any ideas? Thanks in advance for any help you might have to offer.

Upvotes: 3

Views: 4734

Answers (1)

Fabio Ceconello
Fabio Ceconello

Reputation: 16049

Notice that the value shown in the documentation for HAYSTACK_SITECONF is an example only. The real name should be the module where the SearchIndex-derived classes are defined. So, as in your case the module is search_indexes, then you should have HAYSTACK_SITECONF='search_indexes' Also, about that error that appears at the interpreter, did you get it using python ./manage.py shell? If not, settings.py wasn't loaded at the interpreter.

Upvotes: 1

Related Questions