[英]Elasticsearch Parse Exception error when attempting to index PDF
我刚刚开始使用elasticsearch。 我们的要求是我们需要索引数千个PDF文件,而我很难获得其中一个成功编制索引。
安装了Attachment Type插件并得到了响应: Installed mapper-attachments
。
遵循附件类型操作教程但该过程挂起, 我不知道如何解释错误消息 。 还尝试了挂在同一个地方的要点 。
$ curl -X POST "localhost:9200/test/attachment/" -d json.file
{"error":"ElasticSearchParseException[Failed to derive xcontent from (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108, 101]]","status":400}
更多细节:
json.file
包含一个嵌入式Base64 PDF文件(根据说明)。 该文件的第一行显示正确(无论如何): {"file":"JVBERi0xLjQNJeLjz9MNCjE1OCAwIG9iaiA8
...
我不确定json.file
是否无效或者是否可能没有设置json.file
来正确解析PDF?!?
编码 - 以下是我们如何将PDF编码为json.file
(根据教程):
coded=`cat fn6742.pdf | perl -MMIME::Base64 -ne 'print encode_base64($_)'`
json="{\"file\":\"${coded}\"}"
echo "$json" > json.file
还尝试过:
coded=`openssl base64 -in fn6742.pdf
日志:
[2012-06-07 12:32:16,742][DEBUG][action.index ] [Bailey, Paul] [test][0], node[AHLHFKBWSsuPnTIRVhNcuw], [P], s[STARTED]: Failed to execute [index {[test][attachment][DauMB-vtTIaYGyKD4P8Y_w], source[json.file]}]
org.elasticsearch.ElasticSearchParseException: Failed to derive xcontent from (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108, 101]
at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:147)
at org.elasticsearch.common.xcontent.XContentHelper.createParser(XContentHelper.java:50)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:451)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:437)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:290)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:210)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
希望有人可以帮我看看我错过了什么或做错了什么?
以下错误指向问题的根源。
Failed to derive xcontent from (offset=0, length=9): [106, 115, 111, 110, 46, 102, 105, 108, 101]
UTF-8代码[106,115,111,...]表明您正在尝试索引字符串“json.file”而不是文件的内容。
要索引文件的内容,只需在文件名前添加字母“@”即可。
curl -X POST "localhost:9200/test/attachment/" -d @json.file
事实证明,在“无头”服务器上运行java应用程序之前,必须export ES_JAVA_OPTS=-Djava.awt.headless=true
...谁会想到的?!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.