0

can elastic search index values such as

"key": [
            14.0,
            "somestring"
        ]

if i try to ingest this data, i get this error

org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: Found unrecoverable error [Bad Request(400) - [WriteFailureException; nested: MapperParsingException[failed to parse [FIXMessage.key]]; nested: NumberFormatException[For input string: "somestring"]; ]]; Bailing out..

first, is the above a valid JSON format ? If so, then why is elastic not able to index it?

AbtPst
  • 7,778
  • 17
  • 91
  • 172

2 Answers2

2

Elasticsearch is trying to convert "somestring" to number, and failing.

Your json is valid, and Elasticsearch will happily index multiple values for the same field from an array of values, but they have to all have the same type, and the type must match the type of the corresponding field in the mapping.

If the field doesn't exist in the mapping, Elasticsearch will create it using a sensible default type based on the first value it sees for that field. So if you tried to index what you posted above, and the "key" field didn't exist, Elasticsearch would create the field, look at the first value it found (14.0) and decide to use the float type. Then it would try to index the second value, "somestring", fail to convert it to a float, and send back an error.

Make sense?

You might find this post helpful.

Sloan Ahrens
  • 8,588
  • 2
  • 29
  • 31
1

It depends on what you plan to do with the data. If you only want to store and to get the full array, you can simply convert the JSON array as string.

When you want to get the array from Elastic, that you have to convert back from string to JSON array.

If you want also to search inside this array, you can split the array into multiple arrays, distinguish it after type.

banuj
  • 3,080
  • 28
  • 34