I'm experiencing a strange issue. I've got an index with a template where a given mapping is specified. Such a mapping includes a specific field which should be a long.
It works perfectly for almost all the documents in the index, but for some of them, even if the field acts as a long (I can do metric like avg and max over it), it does look like a string in the JSON.
Apparently it is causing some problems when another team queries ES via API, since the returned value is a string.
Here it is how the field appears (correctly) in most of the documents
Mhmh interesting... shouldn't it be true by default anyway?
However, thank you so much for your prompt and useful reply.
For anybody interested in fixing the same issue without reindexing with the coerce set to true, here's the ingest pipeline I used to update the index:
{
"string_to_long_pipeline" : {
"description" : "Convert a specific field from String to Long where needed",
"processors" : [
{
"script" : {
"source" : """
if (ctx.containsKey('specific_field') && ctx.specific_field instanceof String) {
def to_long = Long.parseLong(ctx.specific_field);
ctx.specific_field = to_long
}
"""
}
}
]
}
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.