elasticsearch - 如何使用Elasticsearch 5.5.1为文件建立索引

标签 elasticsearch kibana

我是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/

相关文章:

elasticsearch - 聚合,查询上下文和过滤器上下文在Elasticsearch 5.1中不起作用

elasticsearch - ElasticSearch-查询以过滤和聚合嵌套对象术语

histogram - 自定义 kibana 直方图

kibana - Elastic Kibana - 安装为 Windows 服务

elasticsearch - 使用ELK处理来自同一台机器的多个日志

elasticsearch - 可以列出丢失数据的唯一ID的Elasticsearch查询

elasticsearch - 配置文件中的 Logstash 变量定义

logging - Logstash 输入文件 - 从桌面文件读取

elasticsearch - kibana没有按时间分组

elasticsearch - 在NEST 2.3.3中(由NEST 1.6.2升级)替换了TermsExecution。