Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the example below, the source for entities has been configured to iterateOver the document metadata "victims."

In the example, frequency calls the function getVictimCount, previously imported into the script engine, using the $FUNC() block.  For more information about calling imported javascript functions, see Javascript globals.

 

Code Block
  },
                {
                    "dimension": "Who",
                    "disambiguated_name": "$FUNC( getVictim(); )",
                    "frequency": "$FUNC( getVictimCount(); )",
                    "type": "VictimType",
                    "useDocGeo": false,
                    "iterateOver": "victim"
                },
                {
                    "dimension": "Who",
                    "disambiguated_name": "$FUNC( getVictim(); )",
                    "frequency": "$hostagecount",
                    "type": "HostageType",
                    "useDocGeo": false,
                    "iterateOver": "victim"
                }
            ]
        },

...

In the example source, the entity block is configured to output an entity using the dimension "where."  The location is determined using javascript, and the scripts are calling on function methods defined in the javascript Globals section.

In the example, inline javascript is used by enclosing the javascript in the $SCRIPT() block.  For more information about inline javascript, see Javascript globals.

Code Block
 },                {
                    "dimension": "Where",
                    "disambiguated_name": "$metadata.json.actor.location.displayName",
                    "geotag": {
                        "city": "$SCRIPT( return getAddressVal( _doc.metadata.json[0].actor.location.displayName, 0 ) )",
                        "stateProvince": "$SCRIPT( return getRegion(getAddressVal( _doc.metadata.json[0].actor.location.displayName, 1 )) )",
                        "countryCode": "US",
                        "alternatives": [
                            {
                                "stateProvince": "$SCRIPT( return getRegion(getAddressVal( _doc.metadata.json[0].actor.location.displayName, 1 )) )",
                                "countryCode": "US"
                            }
                        ]
                    },

...