haystack v2.0.0-beta,pyelasticsearch 0.0.6。当我尝试运行 "python managy rebuid_index" 时,出现错误:
File "/usr/lib/python2.6/site-packages/pyelasticsearch-0.0.6-py2.6.egg/pyelasticsearch.py", line 266, in bulk_index
response = self._send_request('POST', path, body, {'op_type':'create'}, prepare_body=False)
TypeError:_send_request() 得到了一个意外的关键字参数“prepare_body”
pyelasticsearch.py 中的详细信息:
#+
def bulk_index(self, index, doc_type, docs, id_field="id"):
"""
Indexes a list of documents as efficiently as possible.
"""
body_bits = []
if not len(docs):
raise ElasticSearchError("No documents provided for bulk indexing!")
for doc in docs:
action = {"index": {"_index": index, "_type": doc_type}}
if doc.get(id_field):
action['index']['_id'] = doc[id_field]
body_bits.append(self._prep_request(action))
body_bits.append(self._prep_request(doc))
path = self._make_path(['_bulk'])
# Need the trailing newline.
body = '\n'.join(body_bits) + '\n'
response = self._send_request('POST', path, body, {'op_type':'create'}, prepare_body=False)
return response
#+
实际上,我自己添加了 bulk_index,在错误“ self.conn.bulk_index(self.index_name, 'modelresult', prepped_docs, id_field=ID)
AttributeError: 'ElasticSearch' object has no attribute 'bulk_index'
”之后,点击链接https://github.com/toastdriven/pyelasticsearch/blob/master/pyelasticsearch.py #L424-469
有人有同样的经历吗?任何建议和参考将不胜感激。