How to solve this error

method [POST], host [http://localhost:9200], URI [/euronews/mytable/1266?pretty=true], status line [HTTP/1.1 400 Bad Request]
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "failed to parse"
}
],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse",
"caused_by" : {
"type" : "json_parse_exception",
"reason" : "Unexpected character ('f' (code 102)): was expecting comma to separate Object entries\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@77d3355e; line: 2, column: 45]"
}
},
"status" : 400
}

Can you show the body of the mapping?

{
"euronews": {
"aliases": {},
"mappings": {
"mytable": {
"properties": {
"body": {
"type": "text",
"analyzer": "std_english"
},
"lineNo": {
"type": "long"
}
}
}
}

You don't need to provide the index name in the body, and you've got a few extra close braces in there as well. Try this:

PUT euronews
{
  "aliases": {
  }, 
  "mappings": {
    "mytable": {
      "properties": {
        "body": {
          "type": "text",
          "analyzer": "std_english"
        },
        "lineNo": {
          "type": "long"
        }
      }
    }
  }
}

I had to change the analyser to english but that created the index on my machine.

Hope this helps.

what about this error:

{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "failed to parse"
}
],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse",
"caused_by" : {
"type" : "json_parse_exception",
"reason" : "Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@69c6b504; line: 2, column: 15]"
}
},
"status" : 400
}

Are you indexing a document or creating a mapping? In the first post, the URL looks like you're indexing a document but the error made me think you're creating a mapping using the wrong API.

If you're indexing, can you show the body of the document you're trying to index? There's likely a problem in the body of the request.

i am trying to enter data into my index using a program in java but it fails due to presence of "" and ' in body part of my data.the id part is ok. so could you help me with some code to insert data to my index in python or java

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.