Mapper Parsing Exception in elasticsearch

i have installed the mapper attachment plugin successfully.i am using Elasticsearch - 1.7.3 and mapper attachment - 2.7.1. i want to use attachments for searching purpose. with the help of this link https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.7.1/#version-271-for-elasticsearch-17 i was trying to understand how it is done

i complete the first step i.e i have set a json element as attachment through this
PUT /test/person/_mapping
{
"person" : {
"properties" : {
"my_attachment" : { "type" : "attachment" }
}
}
}
it worked, but in the second step i.e
PUT /test/person/1
{
"my_attachment" : "... base64 encoded attachment ..."
}
i got a mapper parsing exception. i am using postman for this. i have not used elasticsearch before so please help me to resolve this error please reply asap

thanks
tarneet

If you post the full error, that could help. May be with logs.

{
"error": "MapperParsingException[failed to parse]; nested: JsonParseException[Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character '.' (code 0x2e) in base64 content\n at [Source: [B@e946b; line: 2, column: 25]]; ",
"status": 400
}

[2015-10-23 14:34:48,281][INFO ][cluster.metadata ] [Lockjaw] [test] cre
ate_mapping [person]
[2015-10-23 14:35:21,791][DEBUG][action.index ] [Lockjaw] [test][2],
node[pCltRcnLRamM0Ch9Hke3xg], [P], s[STARTED]: Failed to execute [index {[test]
[person][1], source[{
"my_attachment" : "... base64 encoded attachment ..."
}]}]
org.elasticsearch.index.mapper.MapperParsingException: failed to parse
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.ja
va:565)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.ja
va:493)
at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java
:493)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnP
rimary(TransportIndexAction.java:192)
at org.elasticsearch.action.support.replication.TransportShardReplicatio
nOperationAction$PrimaryPhase.performOnPrimary(TransportShardReplicationOperatio
nAction.java:574)
at org.elasticsearch.action.support.replication.TransportShardReplicatio
nOperationAction$PrimaryPhase$1.doRun(TransportShardReplicationOperationAction.j
ava:440)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(Abstrac
tRunnable.java:36)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.common.jackson.core.JsonParseException: Failed to d
ecode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character '.' (code 0x
2e) in base64 content
at [Source: [B@e946b; line: 2, column: 25]
at org.elasticsearch.common.jackson.core.JsonParser._constructError(Json
Parser.java:1487)
at org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.getBi
naryValue(UTF8StreamJsonParser.java:444)
at org.elasticsearch.common.jackson.core.JsonParser.getBinaryValue(JsonP
arser.java:1131)
at org.elasticsearch.common.xcontent.json.JsonXContentParser.binaryValue
(JsonXContentParser.java:188)
at org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(Atta
chmentMapper.java:390)
at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(Obj
ectMapper.java:706)
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper
.java:497)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.ja
va:544)

Your BASE64 encoding is "incorrect " as it's on multiple lines.

You should have no \n within the value.

how to remove this \n and in which file??
actually the thing is users will upload a file and i want to search users by the help of uploaded files

You have to generate BASE64 strings without Line breaks.
I'm not saying you should remove line breaks in files themselves.

Instead of sending incorrect JSON like:

"field": "AAAAAAAAAAAA
AAAAAAAAAA"

Send:

"field": "AAAAAAAAAAAAAAAAAAAAAA"

ya it worked thank you very much sir

can you tell me one more thing when user send their file, should it be first converted into base64?
and also when we do the searching what code should i use??

for simple text search i do this:
$query = $es->search([
'body' => [
'query' => [
'bool' => [
'should' => [
'match' => ['skills2' => $q],
'match' => ['location2' => $l]
]
]
]
]
]);
if($query['hits']['total'] >= 1){
$results = $query['hits']['hits'];
}
skills2 and location2 are just field names
and it worked but for files i do not know what code to use??

I don't exactly understand the question. You need to provide to elasticsearch a JSON document. The only way to add a binary content in a JSon document is by converting it first to BASE64.

About searching, you have many examples I think on the mapper attachments plugin README file.

ok thank you sir