1
elasticsearch 2.3.4およびpythonを使用してPDFを索引付けしようとしています。 pdfからテキストとメタデータを抽出して索引付けしたい。 mapper_attachmentプラグインを使用しています。elasticsearchでpdfを索引付けするときのmapper_parsing_exceptionエラー
インデックスを作成しようとしているときに、「mapper_parsing_exception」エラーが発生しました。私のコードで続き、
#Configuration
DIR = 'D:/QA_Testing/testing/data'
ES_HOST = {"host" : "localhost", "port" : 9200}
INDEX_NAME = 'testing'
TYPE_NAME = 'documents'
URL = "D:/xyz.pdf"
es = Elasticsearch(hosts = [ES_HOST])
mapping = {
"mappings": {
"documents": {
"properties": {
"cv": { "type": "attachment" }
}}}}
file64 = open(URL, "rb").read().encode("base64")
data_dict = {'cv': file64}
data_dict = json.dumps(data_dict)
res = es.indices.create(index = INDEX_NAME, body = mapping)
es.index(index = INDEX_NAME, body = data_dict ,doc_type = "attachment", id=1)
ERROR:
Traceback (most recent call last):
File "C:/Users/537095/Desktop/QA/IndexingWorkspace/MainWorkspace/index3.py", line 51, in <module>
es.index(index = INDEX_NAME, body = data_dict ,doc_type = "attachment", id=1)
File "C:\Python27\lib\site-packages\elasticsearch\client\utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "C:\Python27\lib\site-packages\elasticsearch\client\__init__.py", line 261, in index
_make_path(index, doc_type, id), params=params, body=body)
File "C:\Python27\lib\site-packages\elasticsearch\transport.py", line 329, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "C:\Python27\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 106, in perform_request
self._raise_error(response.status, raw_data)
File "C:\Python27\lib\site-packages\elasticsearch\connection\base.py", line 105, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
RequestError: TransportError(400, u'mapper_parsing_exception', u'failed to parse')
私が間違って何をやっていますか?あなたのdoc_type
を変更する必要が
'DOC_TYPEは= "添付ファイル"' 'DOC_TYPE = "ドキュメント"'でなければなりませんでなければなりません。また、ESサーバーのログに表示されるエラーを表示できますか? – Val
ありがとうございます!私の愚かな間違い。その仕事は今:) – pavancs