2016-11-21 5 views
0

Ich baue eine Django-Anwendung mit Haystack + Whoosh für die Suche. In der Entwicklungsumgebung funktioniert die Suche wie erwartet. In der Produktion liefern Suchvorgänge jedoch konsistent keine Ergebnisse.Django + Haystack + Whoosh, keine Ergebnisse in der Produktion

Entwicklung:

$> python manage.py rebuild_index 
... 
All documents removed. 
Indexing 8 categories 
Indexing 4 documents 

$> python manage.py shell 
... 
>>> from haystack.query import SearchQuerySet 
>>> SearchQuerySet().all().count() 
12 

Produktion:

$> dokku run proj python manage.py rebuild_index -v2 
... 
All documents removed. 
Skipping '<class 'django.contrib.admin.models.LogEntry'>' - no index. 
... 
Skipping '<class 'django.contrib.sessions.models.Session'>' - no index. 
Indexing 7 categories 
    indexed 1 - 7 of 7 (worker PID: 8). 
Indexing 13 documents 
    indexed 1 - 13 of 13 (worker PID: 8). 
[INFO/MainProcess] process shutting down 

$> dokku run proj python manage.py shell 
... 
>>> from haystack.query import SearchQuerySet 
>>> SearchQuerySet().all().count() 
0 
>>> from django.conf import settings 
>>> settings.HAYSTACK_CONNECTIONS['default']['PATH'] 
'/app/whoosh/index' 

$> dokku run proj ls -la /app/whoosh 
total 8 
drwxr-xr-x 2 herokuishuser herokuishuser 4096 Nov 21 16:44 . 
drwxr-xr-x 21 herokuishuser herokuishuser 4096 Nov 22 17:42 .. 
-rw-r--r-- 1 herokuishuser herokuishuser 0 Nov 21 16:43 .gitkeep 

Dateien/Einstellungen:

# requirements.txt 
Django==1.10.3 
django-haystack==2.5.1 
gunicorn==19.6.0 
psycopg2==2.6.2 
whitenoise==3.2.2 
Whoosh==2.7.4 
... 

# runtime.txt 
python-3.5.2 

# proj/settings.py 
... 
HAYSTACK_CONNECTIONS = { 
    'default': { 
     'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 
     'PATH': os.path.join(BASE_DIR, 'whoosh', 'index'), 
    }, 
} 
... 

Jede mögliche Anleitung auf das Problem gefunden?

Antwort

0

Es könnte sich um ein Berechtigungsproblem handeln.

Sie im ausführlichen Modus ausführen können, können Sie Einsicht aus, dass bekommen:

dokku run proj python manage.py rebuild_index -v2 

Was in Ihren Einstellungen ist? Sie sollten etwas haben wie:

HAYSTACK_CONNECTIONS = { 
    'default': { 
     'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 
     'PATH': os.path.join(self.BASE, '_whoosh', 'whoosh_index'), 
    }, 
} 

Drucken Sie settings.HAYSTACK_CONNECTIONS['default']['PATH']. Stellen Sie sicher, dass sich diese Datei nicht in einem temporären Ordner befindet und auf sie zugegriffen werden kann (ls -la ...).

+0

Danke - es sieht so aus, als ob die Indexdatei nicht erstellt wird - siehe die obigen Änderungen. –