我是Elasticsearch的新手。我已经使用Kibana,X-pack和摄取附件成功安装了Elasticsearch。我同时运行Elasticsearch和Kibana。目前,我使用Windows 2012服务器上的默认选项进行安装,使其保持简单。我在另一个驱动器w\mydocs
上有一个目录,目前它只有3个纯文本文件,但是我想添加其他文件,例如pdf和doc文件类型。所以现在我想将这些文件放入Elasticsearches索引中。我尝试使用以下链接作为指南Attaching pdf docs in Elasticsearch,但是无法正常工作。
这是我设置索引和管道的方法:
PUT _ingest/pipeline/docs
{
"description": "documents",
"processors" : [
{
"attachment" : {
"field": "data",
"indexed_chars" : -1
}
}]
}
PUT myindex
{
"mappings" : {
"documents" : {
"properties" : {
"attachment.data" : {
"type": "text",
"analyzer": "standard"
}
}
}
}
}
然后,要获取第一个文档,请使用以下命令:
PUT localhost:9200/documents/1?pipeline=docs -d @/w/mydocs/README.TXT
我收到的错误是:
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "request body is required"
}
],
"type": "parse_exception",
"reason": "request body is required"
},
"status": 400
}
最佳答案
即使索引二进制数据,您仍然必须将有效的JSON发送到Elasticsearch。这意味着,您必须将文档编码为base64,然后将其放入这样的JSON文档中
{
"data" : "base64encodedcontentofyourfile"
}
关于elasticsearch - 如何使用Elasticsearch 5.5.1为文件建立索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45464994/