Hi
We are in a process of migrating ES from 1.5.2 to 6.1.1 and we hit a problem.
We have an index where one of the properties is of type "double".
The value for the property in the documents loaded into the index is 0.0.
Unfortunately when i query the index the results of the document is returned as 0, which is breaking my client code whose data type is autosuggested to long rather than double.
Are you sure that you're sending "0.0" in the document source ? Can you show a sample document which contains "0.0" in its source, but "0" comes back in the results ?
The mapping you linked to is defined in the parent_measure_code index but the document you're showing comes from the parent_code index. Can you show the mapping from your parent_code index, too?
its indeed parent_measure_code, I changed the index name and deleted few unwanted fields in my first post. The information I shared in the links are the actual ones
The source you're seeing (3rd link) is really exactly what you have sent to ES. ES does never modify the source document. So we need more insights into how your indexing process looks like. Does that happen via Logstash?
Hi, Is there a way at least to override the default behavior and return the values honoring the datatypes of the fields. May be any plugin where i can transform the json response.
One thing you might want to try is to send your field as a string (but keep the float type in the mapping !!) and thus the value will be unaltered when it comes back
In your Logstash config you need to add a mutate/convert filter
Thanks for the information.
But It won't help, as there are many fields (float) whose values are 0.0 being returned as 0 across multiple docs.
I'm looking for a fix at core level by sending the appropriate json value based on the field data type, so that the json result is mapped correctly at client end.
If you any ideas to change the behavior in base code or via plugins, pls don't mind dropping drop it at niranjan.518@gmail.com. As said earlier, I'm in a bad need of the fix.
The ObjectMapper class from jackson library auto detects the java datatype based on the json value from ES Results and creates the HashMap of the fields from json. So now 2 documents from same index with values of 0 and 0.0 for a given field will create 2 objects with different datatypes, Integer and Double. Which is wrong. We explicitly dont provide data type mapping while tranforming results, but rather rely on ES fields data types.
After debugging the elastic search code, I found that the issue is with logstash elastic search plugin. ES never saw 0.0 in the source. It is the plugin that is converting 0.0 to 0 while putting the doc into the ES, but stdout prints 0.0 to console. Im still wondering about the odd behavior of the plugin to strip the .0
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.