# Policy for the selection of metadata rules

The metadata of a file may satisfy more than one rule. When this happens, the rule to apply is determined based on these aspects:

1. The rule with the most metadata is chosen.
2. If there are several rules with the same number of metadata, the rule with the lower tolerance is used. The tolerance is determined by the presence (or absence) of wildcards (\* and ?) in the metadata of the rule. A metadata without wildcards has 0 tolerance, a metadata with ? has a tolerance of 1, a metadata with \* has a tolerance of 2.\
   Example:
   * originalFileName=filename1.txt;appId=SCAF;destId=QSEC tolerance 0
   * originalFileName=filename1.txt;appId=SCAF;destId=?SEC tolerance 1
   * originalFileName=\*.txt;appId=SCAF;destId=QSEC tolerance 2
   * originalFileName=\*.txt;appId=SCAF;destId=?SEC tolerance 3\
     In this case, the first one will be chosen, because it has the lowest tolerance.
3. In case of multiple rules with the same number of metadata and the same tolerance, the rule with higher priority is used.
4. In case of multiple rules with the same number of metadata, same tolerance, same priority, the rule with higher priority in the Category (if present in the rule) is used.
5. In case of multiple rules with the same number of metadata, the same tolerance, the same priority in the rule, and the same priority in the Category, the first rule entered is used.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.primeur.com/data-mover-1.21/file-routing/create-a-rule/policy-for-the-selection-of-metadata-rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
