Search code examples
solr

Why was the value changed in Apache solr?


I have some fields of tfloat-type in solr.

But sometime its value is changed by solr probably.

In my case, I gave a value "812095000" Solr, however when I checked it in Solr-Admin, it showed the value was "812094980". I don't get it. Why changed?

And, can I get original values? I mean "812095000".

It looks that only if I give large number, this occurs.


Solution

  • That's how floats work. Floats are not exact, and can't store all exact values. If you need to store a large integer, use long instead.

    Regular 32-bit floats can't store the value 812095000 as you've discovered. Instead, use a type that suits the data you're inputting (if it's integers, use an integer or a long format, or use a double field if you need floating point numbers