Jeeppp
Jeeppp

Reputation: 1573

Increment decimal position in Solr

Making a field as "float" fieldtype converts the source data 50 to 50.0 in the response.

Is there any way I could make it 50.00 by some tweaks in schema??

Upvotes: 0

Views: 114

Answers (1)

MatsLindh
MatsLindh

Reputation: 52892

This responsibility is better handled in your display layer than in the response from Solr (and as far as I know, you can't define a round operation to be performed when a value is retrieved). Floating point values are inherently non-exact, so a different number then 50.0 could end up as 48.99999999999997, etc. This precision also changes depending on how large your numbers are.

Perform rounding in the display layer before displaying any values to the user.

Upvotes: 3

Related Questions