Installing the Redaction Rules
Rules must be installed in the schemas database associated with your content database. Rules must also be part of a collection before you can use them. This section installs rules in the Schemas database, which is the default schemas database associated with the Documents database.
When you complete this exercise, the Schemas database should contain the following documents. The documents are inserted into a rule collection named “gs-rules”. Rules must be in a rule collection before you can apply them.
/rules/gs/redact-phone.xml
/rules/gs/conceal-id.json
The rules installed in this step use the redact-us-phone and conceal built-in redaction functions. For details on these and other built-in redaction functions, see Built-in Redaction Function Reference in the Application Developer’s Guide.
Follow the steps in this procedure to install two sample rules in the Schemas database. For an explanation of what the rules do, see Understanding the Example Rules.
Change directory to the
rules
directory you created in Creating a Work Area. You should be in yourredact-gs/rules
directory.Copy the following text into a file named
redact-phone.xml
.<rule xml:lang="zxx" xmlns="http://marklogic.com/xdmp/redaction"> <description>Obscure phone numbers.</description> <path>//summary</path> <method> <function>redact-us-phone</function> </method> <options> <level>partial</level> </options> </rule>
Copy the following text into a file name
conceal-id.json
:{ "rule": { "description": "Remove customer ids.", "path": "//id", "method": { "function": "conceal" } }}
Run the following mlcp command to insert the rules into the Schemas database. Modify the connection details as needed to match your environment.
$ mlcp.sh import -host localhost -port 8000 \ -username user -password password -mode local \ -database Schemas -input_file_path . \ -output_uri_replace ".*/redact-gs/rules/,'/rules/gs/'" \ -output_collections "gs-rules"
You can use Query Console to explore the Schemas database and confirm the upload.
The use of -output_uri_replace
on the import command line replaces the portion of the default URI that is based on the filesystem location with the fixed directory prefix /rules/gs
. For more details, see Controlling Database URIs During Ingestion.