3

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.

Cadilac
  • 1,090
  • 11
  • 17

1 Answers1

1

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.

Fabio Ceconello
  • 15,819
  • 5
  • 38
  • 51
  • sorry for answering so late, but i was a little busy somewhere else. i am not usuing 2.0.0-alpha version. i give some errors that i get whet i try import haystack (please take a look at my question description) – Cadilac Dec 07 '11 at 17:18
  • OK, I rewrote the answer accordingly – Fabio Ceconello Dec 07 '11 at 22:05
  • after `python ./manage.py shell` i import haystack and type '>>> haystack.__version__' and get `(1, 1, 0)`, i also define `HAYSTACK_SITECONF='search_indexes'` but this time i get `No fields were found in any search_indexes. Please correct this before attempting to search.` It is a hard thing. Have You maybe have any ideas, please? – Cadilac Dec 08 '11 at 17:30
  • Did you define a template for the 'text' property? Notice that haystack expects you to use its convention for where to place and how to name this file, otherwise you have to use the arg template_name or set use_template=False. For the later you'll also have to use the arg model_attr instead. – Fabio Ceconello Dec 08 '11 at 20:54
  • 1
    For the record: I'm using version 1.2.5, which is the latest tag, so results may vary. https://github.com/toastdriven/django-haystack/tags – Fabio Ceconello Dec 08 '11 at 20:56