...
- Extracts the JavaScript code contained within the $SCRIPT() block
Wraps the script with the following generic script block:
Code Block function getValue() { ... }
- Passes the function to the ScriptEngine using the ScriptEngine.eval() method
- Calls the getValue() method using the .invokeFunction() method.
...
Code Block |
---|
var description = _doc.metadata.description[0]; |
Setting Field Values Example
In the following example, doc.metadata.json
is used in javascript, in order to set some metadata values for the ingested Twitter data.
...
Code Block |
---|
}, { "assoc_type": "Event", "entity1_index": "$SCRIPT( return _doc.metadata.json[0].actor.preferredUsername + '/twitterhandle';)", "entity2_index": "$SCRIPT( return _iterator.text + '/hashtag'; )", "iterateOver": "json.twitter_entities.hashtags", "verb": "tweets_about", "verb_category": "tweets_about" }, { |
...
About Arrays
The code block below demonstrates how a field within a document's metadata might hold items in a typical JSON array object.
...