Haystack Whoosh doesn't index everything


I use Haystack v1.0 and Whoosh v1.8.1 to create a custom search engine for my site. Everything works beautifully, but the problem is that I do not get results for a large number of records in my indexed models.

For example, - I have four registered models - participant, guest, event, sponsor. When restoring an index from a django shell, the following occurs:

./manage.py rebuild_index

Indexing 26 members. Indexing 3 events. Indexing <x> guests. Indexing <y> sponsors. 

But when I run the SearchQuery API commands, and also when searching the search page, I cannot search for half the member names. It eludes me that when I can search for 14-15 members, why not. The template file * _text.txt * must be correct, as half of the members are indexed correctly.

You can try this http://www.edciitr.com/search/?q= x
x = Vikesh returns 1 result (as expected)
x = Akshit does not return results (problem!)

Both "Akshit" and "Vikesh" values ​​were present before rebuild_index. Here is a list of all 26 members I'm trying to follow - http://www.edciitr.com/contact/

+4
source share
2 answers

Ok, so here is what I did to find out if there is a problem in Whoosh or Haystack. I opened the django shell and searched for a term that didn't appear in search searches in Search Hackstack SearchQuery:

 ./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 indexes all the data correctly. So now I'm trying the SearchQuery API

 ./manage.py shell $>> from haystack.query import SearchQuerySet $>> sqs = SearchQuerySet().filter(content='akshit') $>> sqs $>> [] 

So, I understand that I have to check the whoosh_backend.py file of the haystack library to see what happens. 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 returns exactly one result for a test query, as expected. Internet browsing works, but I would like to know that the problem with haystack is here.

+3
source

I have a similar symptom and this is the question I asked Django django-haystack cannot import CategoryBase from django categories on first run

Perhaps this is also related to your problem.

0
source

Source: https://habr.com/ru/post/1346608/


All Articles