具有弹性搜索的django haystack - 引发BulkIndexError

时间:2015-09-30 09:51:53

标签: django python-2.7 elasticsearch django-haystack

我遇到问题"在运行此python manage.py rebuild_index?

时引发BulkIndexError

这是我在settings.py文件中的haystack配置

HAYSTACK_CONNECTIONS = {
'default': {
    'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
    'URL': 'http://127.0.0.1:9200/',
    'INDEX_NAME': 'haystack',
    #'SILENTLY_FAIL': False,
},

}

HAYSTACK_SIGNAL_PROCESSOR =' haystack.signals.RealtimeSignalProcessor'

这是我的search_indexes.py

class ProductIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
content_auto = indexes.EdgeNgramField(model_attr='title')

def get_model(self):
    return Product

def index_queryset(self, using=None):
    return self.get_model().objects.all()

这是我的views.py

def search_titles():

products = SearchQuerySet().autocomplete(content_auto=request.POST.get('search_text', ''))

return render_to_response('sea.html', {'products':products})

当我尝试索引我的产品型号时,我运行了这个命令

  

python manage.py rebuild_index

,尚未编入索引。它提出了

  

文件" /home/Documents/swamy/project/env/local/lib/python2.7/site-packages/elasticsearch/helpers/ init .py",line 156,在streaming_bulk中       引发BulkIndexError('%i文档无法索引。'%len(错误),错误)   elasticsearch.helpers.BulkIndexError :(' 500个文档未能索引。'

此错误。

我的型号有21000种产品,任何人都可以帮忙解决这个问题吗? 在此先感谢!

1 个答案:

答案 0 :(得分:0)

Elasticsearch改变了批量索引的创建方式。 您可以使用与django-haystack无缝协作的1.4.0版本。