Elasticsearch fails silently if document has mapping mismatch for a field

后端 未结 2 1871
一生所求
一生所求 2021-02-06 01:59

I am facing a weird issue with Elasticsearch. My mapping specifies that a certain field is of type long. Now accidentally I was trying to index some documents which

2条回答
  •  猫巷女王i
    2021-02-06 02:38

    I suspect your mapping looks similar to this:

    {
        "long_field": {
            "type": "long"
        }
    }
    

    If that's the case, you can set the coerce flag to false as it is true by default and will always try to convert strings to numbers and truncate fractions for integers.

    {
        "long_field": {
            "type": "long",
            "coerce": false
        }
    }
    

    If you do this, the next time you try to index a long field as a string, ES will tell you this:

    MapperParsingException[failed to parse [long_field]]; nested: IllegalArgumentException[Long value passed as String]; 
    

提交回复
热议问题