Painless scripted field can't use ctx._source

Hello

I'm using using 6.4.2

I am trying to use the ctx._source syntax to create a custom field but it just gives error. Using a basic example, all documents have a hostname field of type string. I've tried many permutations of trying to assign ctx._source.hostname to the customer field but nothing works.

"reason": {
					"type": "script_exception",
					"reason": "runtime error",
					"script_stack": ["if (ctx._source.hostname != null) { ", "       ^---- HERE"],
					"script": "if (ctx._source.hostname != null) { ctx._source.hostname; }",
					"lang": "painless",
					"caused_by": {
						"type": "null_pointer_exception",
						"reason": null
					}
				}

Is there a better way to debug this, or can someone suggest a fix please ?

thanks

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