9

I tried posting a _bulk post into elastic search, but it throws:

{
   "took": 1,
   "errors": true,
   "items": [
      {
         "index": {
            "_index": "quick",
            "_type": "parts",
            "_id": "ACI250-2016",
            "status": 400,
            "error": {
               "type": "mapper_parsing_exception",
               "reason": "failed to parse [part]",
               "caused_by": {
                  "type": "number_format_exception",
                  "reason": "For input string: \"250-2016\""
               }
            }
         }
      }
   ]
}

And here's what I'm trying to post:

POST _bulk
{"index":{"_index":"quick","_type":"parts","_id":"ACI250-2016"}}
{"eMfg":"ACI","part":"250-2016"}

And the map is:

{
   "quick": {
      "mappings": {
         "parts": {
            "properties": {
               "app": {
                  "type": "string"
               },
               "eMfg": {
                  "type": "string"
               },
               "fPart": {
                  "type": "long"
               },
               "oPart": {
                  "type": "string"
               },
               "ofPart": {
                  "type": "string"
               },
               "part": {
                  "type": "long"
               },
               "price": {
                  "type": "double"
               },
               "title": {
                  "type": "string"
               }
            }
         }
      }
   }
}
Jared Dunham
  • 1,467
  • 2
  • 17
  • 29
  • What do you get when retrieving the mapping with `GET /quick/_mapping`? `part` is probably a number in your mapping and you're trying to feed it a string. – Val Jan 12 '16 at 14:30
  • what is the mapping of field part? – ChintanShah25 Jan 12 '16 at 14:30
  • 4
    There you go: `part` has type `long` and you're trying to send `"250-2016"`. The reason might be that you've sent a document at some point with a part that was a number and the mapping was created at that time. – Val Jan 12 '16 at 14:32
  • either you change the value or make `part` string – ChintanShah25 Jan 12 '16 at 14:32

1 Answers1

11

According to your mapping, part has type long and you're trying to send "250-2016". The reason might be that you've sent a document at some point with a part that was coercible to a number, e.g. "250" and now you're trying to send a string and it fails.

The best way is to use the mapping above to define a new index with the correct mapping type (see below) and then you can try your bulk import again.

DELETE /quick

PUT /quick
{
      "mappings": {
         "parts": {
            "properties": {
               "app": {
                  "type": "string"
               },
               "eMfg": {
                  "type": "string"
               },
               "fPart": {
                  "type": "long"
               },
               "oPart": {
                  "type": "string"
               },
               "ofPart": {
                  "type": "string"
               },
               "part": {
                  "type": "string"       <-- change this
               },
               "price": {
                  "type": "double"
               },
               "title": {
                  "type": "string"
               }
            }
         }
      }
}
Val
  • 207,596
  • 13
  • 358
  • 360
  • Thanks!! For anyone else who wants to learn more about [elastic mapping](https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-intro.html). – Jared Dunham Jan 12 '16 at 14:45