0

我正在使用 Windows 并且REST API已经安装了附件插件,重新启动elasticsearchattachment_mapping. 但是,我收到一个错误:

我执行了这个:(不工作)

{
http://localhost:9200/documentsx/person/1(post)
}



{
    "my_attachment" : {
        "_content_type" : "application/pdf",
        "_name" : "/sap1.pdf",
        "content" : "... base64 encoded attachment ..."
    }
}

我收到此错误::

{
  "error": "MapperParsingException[failed to parse]; nested: JsonParseException[Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal white space character (code 0x20) as character #3 of 4-char base64 unit: can only used between units\n at [Source: [B@16dd7aa; line: 5, column: 29]]; ",
  "status": 400
}

顺便说一句,如果我删除文件或在上面放一些随机文件名_name会给出相同的错误,我认为它不是在读取文件本身。我哪里错了?

4

1 回答 1

2

为了摆脱这个错误,“content”属性的值需要是一个base64编码的字符串。您需要读取文件的内容并将其转换为 base64 编码字符串,然后将该字符串替换为上面的“... base64 编码附件 ...”。

于 2014-11-04T17:51:47.073 回答