Versions Compared

Key

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

Overview

This toolkit element enables the generation of one or more types of entity based on the document or content metadata. The expressions default to replacement strings, or $SCRIPT(...) can be used to return a string using javascript.

...

where "name" represents the name of a metadata objectThis functionality works as follows:

Functional Specification

For non-nested entity specification objects, the first field in the iterateOver field refers to the metadata object, eg "iterateOver": "location" refers to "_doc.metadata.location".

...

Nesting is supported using the "dot notation" eg if in the above instance, the victim was inside an object (or array of objects) called "more_information", then the "iterateOver" field would be set to "more_information.victim".

(This would be equivalent to the less tidy technique of nesting the Entity Specification JSON object, the first having "iterateOver": "more_information", and containing a second Entity Specification JSON object identical to the original example ( "iterateOver": "location").

About Arrays and Objects:

...

Info

Note that "$metadata.X" won't work inside "iterateOver" clauses, you have to use constructs like "$SCRIPT( return _doc.metadata.X[0]; )" to get at the top-level fields. We will probably fix this at some point.)

 

 If you are iterating over a value then use "_value" in scripts, "$" for normal strings.

Anchor
primitives
primitives
Primitives:

If any of the fields point to primitives (eg B: [ "val1", "val2" ] in the example above) then an error is thrown unless the "creation criteria" script for the nested object is specified.

...

You can use "creationCriteriaScript" scriptlets to filter out unwanted entities. eg when looping over metadata arrays.

Creationcriteriascripts are also useful when using primitives with nested objects, as described here.

Examples

Anchor
basic
basic
Basic 

...

Code Block
 ],    "mediaType": ["Social"],
    "metadata": {"json": [{
        "actor": {
            "displayName": "CRM Buddy",
            "followersCount": "245",
            "friendsCount": "0",
            "id": "id:twitter.com:835627776",
            "image": "http://a0.twimg.com/profile_images/2630355549/8cad59efaddd57283dbb159332336744_normal.jpeg",
            "languages": ["en"],
            "link": "http://www.twitter.com/FocalCRM",
            "links": [{"rel": "me"}],
            "listedCount": "6",
            "objectType": "person",
            "postedTime": "2012-09-20T13:59:56.000Z",
            "preferredUsername": "FocalCRM",
            "statusesCount": "3688",
            "summary": "",
            "verified": "false"
        },

 

...

Extracting Entities From Arrays with iterateOver

You can use iterateOver to create an entity for each object in an array.

...

Code Block
"victim": [
            {
                "child": "No",
                "combatant": "No",
                "deadcount": "1",
                "definingcharacteristic": "Unknown",
                "hostagecount": "0",
                "indicator": "Targeted",
                "nationality": "Afghanistan",
                "targetedcharacteristic": "Unknown",
                "victimtype": "Civilian",
                "woundedcount": "4"
            },
            {
                "child": "Yes",
                "combatant": "No",
                "deadcount": "2",
                "definingcharacteristic": "Unknown",
                "hostagecount": "0",
                "indicator": "Targeted",
                "nationality": "Afghanistan",
                "targetedcharacteristic": "Unknown",
                "victimtype": "Civilian",
                "woundedcount": "0"
            }
        ],

 

 

 

...

Specifying Entity Geographic Location

It is also possible to set values for entity parameters using Javascript functions declared in Globals.

...