Scripts may be no longer than 16384 characters


(bfc) #1

I am using Elasticsearch on my Magento store and I found a problem when searching for product, but only for some search strings

Here is the error log:
{"0":"{"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":,"script":"def s =
def id = Long.toString(doc['id'].value); return s[id];","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Scripts may be no longer than 16384 characters. The passed in script is 29931 characters. Consider using a plugin if a script longer than this length is a requirement."}}}}],"caused_by":

Any Idea how to solve this?
I am using Elasticsearch 6.5.1 on Centos7


(Jack Conradson) #2

I just want to be sure the stack trace isn't hiding anything - would you please copy and paste the exact script that caused this? Thanks!


(bfc) #3

{"0":"{"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":,"script":"def s = ['23353':2383,'12157':2382,'12163':2381,'12166':2380,'20304':2379,'23535':2378,'12161'......,]; def id = Long.toString(doc['id'].value); return s[id];","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"default_product_idx1","node":"tO4GMfe-QJ6joi_GlhvV1A","reason":{"type":"query_shard_exception","reason":"script_score: the script could not be loaded","index_uuid":"k9ipkQZQRweLruAdHTIrSg","index":"default_product_idx1","caused_by":{"type":"script_exception","reason":"compile error","script_stack":,"script":"def s = ['23353':2383,'12157':2382,'12163':2381,'12166':2380,'20304':2379,'23535':2378,'12161':2377,'12165'....]; def id = Long.toString(doc['id'].value); return s[id];","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Scripts may be no longer than 16384 characters. The passed in script is 29931 characters. Consider using a plugin if a script longer than this length is a requirement."}}}}],"caused_by":{"type":"script_exception","reason":"compile error","script_stack":,"script":"def s = ['23353':2383,'12157':2382,'12163':2381,'12166':2380,'20304':2379,'23535':2378,'12161':2377,...]; def id = Long.toString(doc['id'].value); return s[id];","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Scripts may be no longer than 16384 characters. The passed in script is 29931 characters. Consider using a plugin if a script longer than this length is a requirement."}}},"status":400}","1":"#0 /home/bfcshop/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(279): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array)


(Jack Conradson) #4

So, unfortunately, there is a hard limit for Painless scripts in 6.5 of 16834 characters. This will be reduced to a soft limit in 6.6 (https://github.com/elastic/elasticsearch/pull/35184). The script in question appears that its generating some kind of data as part of the variable s. This data should either be passed in as part of params or needs to be reduced in overall size for the script to work.