django-haystack空间搜索要求?

时间:2013-11-29 13:44:01

标签: python django django-haystack geodjango

我正在尝试使用django-haystack进行地理空间查询,如下所述:http://django-haystack.readthedocs.org/en/latest/spatial.html我正在使用elasticsearch作为后端。我根据文档创建了search_indexes,配置了django,当我第一次尝试使用rebuild_index管理命令时,我看到了一个错误:

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

干草堆用于从django.contrib.gis.geos进行空间搜索的点无法导入,我不知道为什么。一个完整的工作django.contrib.gis(geodjango)是大海捞针空间搜索的要求吗?换句话说:我必须为geodjango安装所有c库,配置postgis,之后我才能在haystack中使用Point类吗?

sotfware的版本:

  • Django 1.6
  • django-haystack 2.1.0
  • pyelasticsearch 0.6.1
  • elasticsearch 0.90.7

1 个答案:

答案 0 :(得分:7)

我通过安装libgeos和libgeos-dev

解决了这个问题
sudo apt-get install libgeos-dev