Visualising a scripted field is giving me an "unsupported script value" error

Hi folks. I'm trying to extract a value from a queryString in a document, which may or may not be present, and when I try to display this value in a vis, I'm getting an "unsupported script value" error.

My querystring is something like these:

  • ?tabid=123
  • ?tabid=123&something=45

And my Painless script is this:

def q = doc['queryString'].value;

if (q != null) {
int nameStartIndex = q.indexOf('tabid=');
  if (nameStartIndex > 0) {
    nameStartIndex = nameStartIndex + 6;
	
	int nameEndIndex = q.indexOf('&', nameStartIndex);
	if (nameEndIndex > 0) {
	  return q.substring(nameStartIndex, nameEndIndex);
	}
    return q.substring(nameStartIndex);
  }
}

return 0;

This seems to be working, because in my Discover I get some nice results:

image

And if I view the doc, I see

image

But when I put that field into a visualisation, I get an error "Visualize: Unsupported script value [65]"

Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"aggregation_execution_exception","reason":"Unsupported script value [65]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"varnish-2017.09.28","node":"r1pr94XfQ6GRBhiDJJQoIg","reason":{"type":"aggregation_execution_exception","reason":"Unsupported script value [65]"}}]},"status":500}
    at https://mycluster.eu-west-1.aws.found.io/bundles/kibana.bundle.js?v=15443:229:19721
    at Function.Promise.try (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:91:16321)
    at https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:91:15691
    at Array.map (<anonymous>)
    at Function.Promise.map (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:91:15646)
    at callResponseHandlers (https://mycluster.eu-west-1.aws.found.io/bundles/kibana.bundle.js?v=15443:229:19337)
    at https://mycluster.eu-west-1.aws.found.io/bundles/kibana.bundle.js?v=15443:229:7575
    at processQueue (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:38:23621)
    at https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:38:23888
    at Scope.$eval (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:39:4619)
    at Scope.$digest (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:39:2359)
    at Scope.$apply (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:39:5037)
    at done (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:37:25027)
    at completeRequest (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:37:28702)
    at XMLHttpRequest.xhr.onload (https://mycluster.eu-west-1.aws.found.io/bundles/commons.bundle.js?v=15443:37:29634)

What aggregation are you attempting to use this field in? To me it looks like the error is saying that the value the script produces is of the wrong type. I noticed your script returns a string, so if you're attempting to use it as a number ES might balk.

I also just noticed that when q == null you're returning a number, otherwise you're returning a string. You'll always want to return the same type, so that in itself could be an issue.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.