elasticsearch/elasticsearch — pull request #5683 by jprante (2014-04-04 08:16:24+00:00)
Title: BigInteger/BigDecimal support

For XContentBuilder/XContentParser and document mapping, this will add support for "big" numeric types BigInteger/BigDecimal.

BigInteger/BigDecimal support for XContentBuilder/XContentParser is implemented by using the existing Jackson support for the "big" numeric types. A new method `losslessDecimals()` is used to switch the XContentParser into recognizing BigInteger/BigDecimal in precedence over primitive numeric types, for better convenience when using the Java API for parsing document sources with BigInteger/BigDecimal field values.

For the document mapping, new core types `biginteger` and `bigdecimal` are introduced. With a new flag `lossless_numeric_detection`, the precedence of BigInteger/BigDecimal over primitive numeric types can be controlled in the mapping. When set to `true`, new dynamic numeric fields are assigned to "big" numeric types first. Default is `false`, where primitive numeric types still take precedence.

Caveat: BigInteger/BigDecimal support is just meant for search and indexing/storing. The "big" numeric types are degraded to their `.longValue()` and `.doubleValue()` components when they are used in NumericRangeQuery and related contexts, so it is not recommended to use values larger than Long.MAX_VALUE or Double.MAX_VALUE in analytical queries like facets and aggregations, strange cut-offs or underflows/overflows should occur.