4

I am new to Django and Haystack. I have done everything suggested on the "getting started" page of the Haystack Documentation and on the debugging page, but I cannot see where my error lies. sqs.count() returns 0 even though rebuild_index seems to work, giving the right number of entries in the tables being indexed and producing index files into the whoosh_index directory.

search_indexes has the required text = lines, I have a search_sites.py, I have changed the settings.py and urls.py, and I have [model_name]_text.txt files in the right directory.

We are working on a university server where we had to update Django to work with Haystack after we installed Haystack because we realized it was an incompatible version (1.1 not 1.5) - could the old Django have messed with the Haystack installation somehow?

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134

2 Answers2

3

The following code will show you what has been indexed - replace with the correct path for your setup.

from whoosh.index import open_dir
ix = open_dir('<yourapp>/whoosh_indexes')
from pprint import pprint
pprint(list(ix.searcher().documents()))

If that doesn't shed any light you will have to post more details of your code - particularly the search_indexes.py

DaveB
  • 190
  • 1
  • 7
0

This might seem obvious but I had the same error and reading from http://django-haystack.readthedocs.org/en/latest/debugging.html I found out that I was using the wrong attribute name for the returned objects.

   ensure that {{ result.object.title }} corresponds to your model field
   for instance I had name as the model filed but kept wondering why I didn't get results.
   I had to change to {{ result.object.name }} to list my results

name was the needed attribute. Hope this helps someone.

Gideon Maina
  • 849
  • 10
  • 25