我剛剛開始使用elasticsearch。我們的要求讓我們需要索引數千個PDF文件,並且我很難讓其中一個成功索引。Elasticsearch在嘗試索引時解析異常錯誤PDF
安裝了附件類型插件並得到響應:Installed mapper-attachments
。
跟着Attachment Type in Action tutorial但進程掛起和我不知道如何解釋錯誤信息。也嘗試了在同一個地方掛起的gist。
$ 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
無效,或者如果可能elasticsearch只是沒有設置正確地解析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)
希望有人能幫我看看我失蹤或做錯了什麼?
啊,你是對的!謝謝你的幫助!但是,現在我已經嘗試在文件名前添加'@',它只是掛起而沒有輸出到日誌?!?我需要* ctrl-C *來取回我的外殼。有任何想法嗎?也許一種使日誌更有幫助的方法? – Meltemi
你可以運行jstack並查看它掛起的位置嗎? – imotov
我有同樣的錯誤。謝謝! – ssoto