I have a scripted field that generates a URL.
Example data:
{
"field1": "foo",
"field2": "bar",
... other fields ...
}
Some records have values for field1/field2, others do not.
Scripted Field Info:
URL Template: https://{{rawValue}}
Script:
if ((doc['field1.keyword'].value != null) && (doc['field2.keyword'].value != null)) {
// I pull field1/field2 out of `doc`, but for simplicity:
return 'host/field1/field2'
} else {
return 'url.does.not.exist.com/does/not/exist'
}
So currently, it generates a valid URL for documents that have field1 and field2, and generates a nonsensical URL for documents that don't have field1/field2.
So my results look like:
field1 | field 2 |scripted_field
--------------------------------------
a | b | https://host/a/b
| | https://url.does.not.exist.com/does/not/exist
What I would like is instead of generating nonsense, being able to return something that makes it not generate a URL at all:
field1 | field 2 |scripted_field
--------------------------------------
a | b | https://host/a/b
| |
Any way that I can do this?
Thanks!