Pre- and post-index trigger is an advanced feature which enables a user to run a third-party program or user-defined script before or after repository indexing. The “Before” or “Pre-Index Trigger” might be useful for starting services, setting logs, updating mapping files, and other utility tasks that only need to be done once, but in time for an index job. The “After” or “Post-Index Trigger” allows the repository to clean up after itself, report on a given action, etc. The command can be executed with a payload parameter which points to a .json file with information about the repository state.
See the log to see that the command was executed once the repository is indexed.
The example of log message:
2020-09-14 14:55:18,969 INFO common.task.CommandTaskExecutor - Command: python /Users/janjezek/tests/test.py --payload=/Users/janjezek/.voyager/hq/temp/triggers/r174732a0292.json
Example of content of the payload file:
{
"agent": "h16ed654cd75",
"checkPipeline": false,
"delta": false,
"path": "",
"pipeline": "standard",
"repo": {
"idMode": "ABSOLUTE",
"path": "/Users/janjezek/tests/pdf",
"agent": "h16ed654cd75",
"archive": {
"deleteAfterExtraction": false,
"enabled": false,
"formats": []
},
"extraction": {"formats": {
"exclude": [],
"include": []
}},
"feature": {
"enabled": false,
"formats": {}
},
"id": "r17421494a7a",
"indexFormats": {
"exclude": [],
"include": []
},
"indexed": 1600087297016,
"link": {"follow": false},
"mimeDetection": "FILENAME",
"name": "pdf",
"ocr": {"formats": []},
"pipeline": "standard",
"triggers": [{
"stage": "PRE_INDEX",
"tasks": ["t174732a0220"]
}],
"type": "folder",
"watch": false,
"_class": "voyager.discovery.path.FolderRepository",
"display": "/Users/janjezek/tests/pdf"
},
"errors": {
"counts": {},
"errors": [50],
"warnings": [50]
},
"id": "S174732a0278",
"progress": {
"count": 0,
"countText": "0 entries",
"stopped": false,
"total": -1,
"units": [
"entry",
"entries"
]
},
"route": [],
"state": "PENDING",
"timeout": -1
}