【问题标题】:django-haystack spatial search requirements?django-haystack 空间搜索要求?
【发布时间】:2013-12-15 17:39:03
【问题描述】:

我正在尝试使用 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

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

软件版本:

  • Django 1.6
  • django-haystack 2.1.0
  • pyelasticsearch 0.6.1
  • 弹性搜索 0.90.7

【问题讨论】:

    标签: python django django-haystack geodjango


    【解决方案1】:

    我通过安装 libgeos 和 libgeos-dev 解决了这个问题

    sudo apt-get install libgeos-dev
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-25
      • 1970-01-01
      • 2013-02-12
      • 2014-07-17
      • 2012-12-29
      • 1970-01-01
      • 2017-02-04
      • 2011-03-26
      相关资源
      最近更新 更多