간단한 매핑을 만듭니다.
curl -XPUT 'localhost:9200/ficherosindex?pretty=true' -d '{
"mappings": {
"items": {
"dynamic": "strict",
"properties" : {
"title" : { "type": "string" },
"body" : { "type": "string" },
"attachments" : { "type": "attachment" }
}}}}'
내가 할 과를 떠나 빈.PUT
title
body
attachments
curl -XPUT 'localhost:9200/ficherosindex/items/1' -d '{
"title": "This is a test title",
"body" : "This is the body of the java",
"attachments" : ""
}'
그런 다음 다음 스크립트를 만들어 파일 attachments
내용으로 필드 를 업데이트하고 .MY_PDF.pdf
base64
#!/bin/sh
coded=`cat MY_PDF.pdf | perl -MMIME::Base64 -ne 'print encode_base64($_)'`
curl -X POST 'localhost:9200/ficherosindex/items/1/_update?pretty=true' -d '{
"doc" : {
"attachments" : \"${coded}\"
}}'
스크립트를 실행할 때 다음 오류가 발생합니다.
{
"error" : {
"root_cause" : [ {
"type" : "json_parse_exception",
"reason" : "Unexpected character ('\\' (code 92)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [B@6c8caddf; line: 3, column: 30]"
} ],
"type" : "json_parse_exception",
"reason" : "Unexpected character ('\\' (code 92)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [B@6c8caddf; line: 3, column: 30]"
},
"status" : 500
}
내가 뭘 잘못하고 있니? 다음 줄을 변경해야할까요?
{
"doc" : {
"attachments" : \"${coded}\"
}}'
나는 또한 운 이 없는 이 솔루션을 시도 했습니다 . 나는 내가 보여주는 명령을 관리해야한다. 먼저없이 항목을 만들 attachments
을 사용하여 다음과 _update
그것에 .PDF의 내용을 추가 할 수 있습니다.
미리 감사드립니다
다음과 같이해야합니다.
#!/bin/sh
coded=`cat MY_PDF.pdf | perl -MMIME::Base64 -ne 'print encode_base64($_)'`
curl -XPOST 'localhost:9200/ficherosindex/items/1/_update?pretty=true' -H "Content-Type: application/json" -d @- <<CURL_DATA
{ "doc": { "attachments": "$coded" }}
CURL_DATA
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다