我是Elasticsearch的新手,我在这里读到https://www.elastic.co/guide/en/elasticsearch/plugins/master/mapper-attachments.html,在elasticsearch 5.0.0中不推荐使用映射器-附件插件。
我现在尝试用新的摄取附件插件索引一个pdf文件并上传附件。
到目前为止,我尝试过的是
curl -H 'Content-Type: application/pdf' -XPOST localhost:9200/test/1 -d @/cygdrive/c/test/test.pdf但我得到以下错误:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400}我希望该pdf文件将被索引和上传。我做错了什么?
我还测试了Elasticsearch 2.3.3,但是mapper-attachments插件对这个版本无效,我不想使用任何旧版本的Elasticsearch。
发布于 2016-10-31 05:54:25
您需要确保已使用以下命令创建了摄取管道:
PUT _ingest/pipeline/attachment
{
"description" : "Extract attachment information",
"processors" : [
{
"attachment" : {
"field" : "data",
"indexed_chars" : -1
}
}
]
}然后,您可以使用所创建的管道对索引执行PUT而不是POST。
PUT my_index/my_type/my_id?pipeline=attachment
{
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}在您的示例中,应该类似于:
curl -H 'Content-Type: application/pdf' -XPUT localhost:9200/test/1?pipeline=attachment -d @/cygdrive/c/test/test.pdf记住,PDF内容必须是base64编码的。
希望能对你有所帮助。
编辑1请务必阅读这些,它对我帮助很大:
编辑2
此外,您还必须安装ingest-attachment插件。
./bin/elasticsearch-plugin install ingest-attachment编辑3
请在创建摄取处理器(附件)之前,创建索引,映射您将使用的字段,并确保映射中有data字段(与附件处理器中的“字段”同名),以便摄取将处理并使用您的pdf内容填充您的data字段。
我在摄取处理器中插入了indexed_chars选项,值为-1,这样您就可以索引大型pdf文件。
编辑4
映射应该是这样的:
PUT my_index
{
"mappings" : {
"my_type" : {
"properties" : {
"attachment.data" : {
"type": "text",
"analyzer" : "brazilian"
}
}
}
}
}在本例中,我使用了巴西过滤器,但您可以删除它或使用您自己的过滤器。
https://stackoverflow.com/questions/37861279
复制相似问题