Pregunta

I'm trying to use django-haystack for geo spatial queries as described here: http://django-haystack.readthedocs.org/en/latest/spatial.html I'm using elasticsearch as backend. I created search_indexes according to documentation, configured django and when I tried to use rebuild_index management command for the first time I saw an error:

python manage.py rebuild_index --settings=myproject.settings.local

WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
Indexing 1 Venues
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  ...
  ...
  File "/f/venvs/myproject/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 161, in update
    prepped_data = index.full_prepare(obj)
  File "/f/venvs/myproject/local/lib/python2.7/site-packages/haystack/indexes.py", line 204, in full_prepare
    self.prepared_data = self.prepare(obj)
  File "/f/venvs/myproject/local/lib/python2.7/site-packages/haystack/indexes.py", line 195, in prepare
    self.prepared_data[field.index_fieldname] = field.prepare(obj)
  File "/f/venvs/myproject/local/lib/python2.7/site-packages/haystack/fields.py", line 167, in prepare
    from haystack.utils.geo import ensure_point
  File "/f/venvs/myproject/local/lib/python2.7/site-packages/haystack/utils/geo.py", line 2, in <module>
    from django.contrib.gis.geos import Point
ImportError: cannot import name Point

Point which is used by haystack for spatial searches from django.contrib.gis.geos cannot be imported and I'm not sure why. Is a full working django.contrib.gis (geodjango) a requirement for spatial search in haystack? In other words: must I install all c libraries for geodjango, configure postgis and only after that i can use a Point class in haystack?

Versions of sotfware:

  • Django 1.6
  • django-haystack 2.1.0
  • pyelasticsearch 0.6.1
  • elasticsearch 0.90.7
¿Fue útil?

Solución

I resolved the problem by installing libgeos and libgeos-dev

sudo apt-get install libgeos-dev
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top