我正在使用連接到Elasticsearch服務器的Django(主分支)和Haystack(主分支)。 Python版本是3.4。用Elasticsearch的草垛拒絕創建搜索索引
搜索索引類看起來是這樣的:
class PageIndex(indexes.SearchIndex, indexes.Indexable):
text = fields.EdgeNgramField(document=True)
name = fields.EdgeNgramField(model_attr='name', boost=2)
tags = fields.EdgeNgramField(model_attr='tags', boost=1.5)
description = fields.EdgeNgramField(model_attr='description_summary', boost=0.9)
def get_model(self):
return Page
def index_queryset(self, using=None):
return self.get_model().objects.filter(created__lte=datetime.datetime.now())
當我試圖創建索引,我收到以下錯誤:
> python manage.py update_index Indexing 7 communities
PUT /haystack [status:400 request:0.013s]
ERROR:root:Error updating page using default
Traceback (most recent call last):
File "/env/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 221, in handle_label
self.update_backend(label, using)
File "/env/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 266, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity)
File "/env/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 89, in do_update
backend.update(index, current_qs)
File "/env/lib/python3.4/site-packages/haystack/backends/elasticsearch_backend.py", line 158, in update
prepped_data = index.full_prepare(obj)
File "/env/lib/python3.4/site-packages/haystack/indexes.py", line 204, in full_prepare
self.prepared_data = self.prepare(obj)
File "/env/lib/python3.4/site-packages/haystack/indexes.py", line 187, in prepare
ID: get_identifier(obj),
File "/env/lib/python3.4/site-packages/haystack/utils/__init__.py", line 33, in default_get_identifier
obj_or_string._meta.module_name,
AttributeError: 'Options' object has no attribute 'module_name'