Adding fields that contain initial values

With the AUTOTAG action you can create a policy that automatically adds fields with initial values to a specified set of documents.

This method is useful when you want to add fields to a set of documents and you know beforehand the values that you want the fields to contain. For example, you might want to add a "billingaddress" field that contains the initial value "100 Corporation Street, Metropolis, USA" to every document that has a "username" field that contains the value "mjsmith". Or you might want to add an "ownerid" field that contains the initial value "admin02" to every document that lies in a certain directory path.

For more information about creating a policy, see the topic /policyengine/v1/policies -d '<data>': POST.

The following example shows how to create a policy that adds a project number and a department code to each document that contains a particular user name:
$ curl -k  -H 'Authorization: Bearer <token>'
https://<spectrum_discover_host>/policyengine/v1/policies/autotagpol1 
-d '{
"pol_filter":"user='research1'", 
"action_id": "AUTOTAG",	
"action_params": {		
    "tags": {"ProjectNumber":"1404", "DepartmentCode":"H8AC"}
    }
"schedule":"NOW"
}'
-X POST -H "Content-Type: application/json"
The preceding example adds the fields "ProjectNumber":"1404" and "DepartmentCode":"H8AC" to every document in which the "user" field is set to 'research1'.