Skip to content

"can not write type [class java.math.BigInteger]" error for script parameters #34656

@bobbyi

Description

@bobbyi

Using ES 6.1.2 (on JVM 1.8.0_121), the following query works on a single-node cluster (unzipping the server dist and running on my laptop), but fails on our production multi-node cluster with "can not write type [class java.math.BigInteger]":

curl http://<host>:9200/<index>/<doctype>/_search -H 'Content-Type: application/json' -d '
{
   "query":{"match_all":{ } },
   "size":0,
   "aggs":{
      "the_agg":{
         "sum":{
            "script":{
               "lang":"painless",
               "inline":"params.limit",
               "params":{
                  "limit":100000000000000000000000000
               }
            }
         }
      }
   }
}
'

If I change the parameter from 100000000000000000000000000 to 100000000000000000000000000.0 or 1E+26 it works (presumably because it treats the value as a double instead of a BigInteger). However, that's not really a useable workaround for me because I simplified this example from an application case where I don't have direct control over the JSON serialization.

I saw issue #32395 (a related issue about BigIntegers) and @mayya-sharipova 's comments there, but I'm not sure if the commits for that issue also fix this one since that one is about source filtering.

I saw issue #26364 and the comments from @jdconrad / @nik9000 there . I'm not sure if this is duplicate or a closely related issue. It seems that the solution there was to write the application in Java with the Transport Client that will write the JSON so the value looks like a double, but I don't think that is a possible solution for everyone and think that there is an actual bug here in that the above query using curl does not work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Core/Infra/ScriptingScripting abstractions, Painless, and Mustache

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions