Haystack Whoosh not indexing everything
For e.g. - I have four registered models - Member, Guest, Event, Sponsor. On rebuilding index from django shell, following happens:
./manage.py rebuild_index
Indexing 26 members.
Indexing 3 events.
Indexing <x> guests.
Indexing <y> sponsors.
But on running the SearchQuery API commands and also on searching through the search page, I cannot 开发者_如何学编程search half the member names. What eludes me is that when I can search 14-15 members, why not the rest. My template *_text.txt* file should be correct since half the members are getting indexed correctly.
You can try this
http://www.edciitr.com/search/?q=x x= Vikesh returns 1 result (as expected) x= Akshit returns no results (the problem!)Both values 'Akshit' and 'Vikesh' were present prior to rebuild_index. Here's the list of all 26 members that I am trying to search - http://www.edciitr.com/contact/
Okay, so here's what I did to find out whether the problem is in Whoosh or Haystack. I opened the django shell and performed a search for the term that was not showing up in haystack SearchQuery API search:
./manage.py shell
$>> import whoosh
$>> from whoosh.query import *
$>> from whoosh.index import open_dir
$>> ix = open_dir('/home/somedir/my_project/haystack/whoosh/')
$>> ix.schema
<Schema: ['branch', 'category', 'coordinator', 'date_event', 'designation','details', 'django_ct', 'django_id'> 'name', 'organisation', 'overview','text', 'title']>
$>> searcher = ix.searcher()
$>> res = searcher.search(Term('text',u'akshit'))
$>> print res
<Top 1 Results for Term('text', 'akshit') runtime=0.000741004943848>
$>> print res['0']['name']
u'Akshit Khurana'
So you see, Whoosh is correctly indexing all data. So, now I try the SearchQuery API
./manage.py shell
$>> from haystack.query import SearchQuerySet
$>> sqs = SearchQuerySet().filter(content='akshit')
$>> sqs
$>> []
So, I realize that I must check out the whoosh_backend.py file of the haystack library to see what's happening. Open - haystack.backends.whoosh_backend around line number 345
'''Uncomment these two lines because the raw_results set becomes empty after the filter call for some queries''
if narrowed_results:
raw_results.filter(narrowed_results)
to
#if narrowed_results:
#raw_results.filter(narrowed_results)
And then it works. SearchQueryAPI returning exactly one result for the test query as expected. Web search working but I would like to know what's the issue with haystack here.
I have a similar symptom, and this is the question I asked Django django-haystack cannot import CategoryBase from django-categories on the first run
Might relate to your problem too.
精彩评论