Hi Paresh,
If you want to sort on the field, I think it has to be the same type. So if
you make everything a double, it should work for all numeric fields. To do
that, you can use dynamic templates
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/mapping-root-object-type.html#_dynamic_templates>.
For example if you have this:
"mappings" : {
"_default_" : {
"dynamic_templates" : [ {
"long_to_float" : {
"match" : "*",
"match_mapping_type" : "long",
"mapping" : {
"type" : "float"
}
}
} ]
}
}
And add a new field with value=32, the field would be mapped as float
instead of long.
Best regards,
Radu
--
Performance Monitoring * Log Analytics * Search Analytics
Solr & Elasticsearch Support * http://sematext.com/
On Thu, Jan 8, 2015 at 11:14 AM, Paresh Behede <[email protected]> wrote:
> Hi,
>
> I have requirement of storing document in elastic search which will have
> dynamic fields + those fields could have different data types values...
>
> For e.g.,
> Document 1 could have age field with value = 32, so when I would insert
> 1st document in ES my index mapping will get created and age will be mapped
> to Integer/Long
>
> Now if I get age = 32.5 in another document ES will throw me exception of
> data type mismatch...
>
> Can you suggest what can I do to handle such scenario?
>
> As workaround we are creating different fields for different data types
> like age.long / age.double but this also won't work if I have to do sorting
> over age field...
>
> Kindly suggest...
>
> Thanks in advance,
> Paresh Behede
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/ec663bd5-cf3b-4a3f-8828-03c4c53d3837%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/ec663bd5-cf3b-4a3f-8828-03c4c53d3837%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAHXA0_09uEGnDtJegPyZ-FY%2BUeCzDs_N1_%2BPsCYxCHu7_ErZVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.