Open topic with navigation

# Run a Lua Script after Ingestion

You can configure the connector to run a Lua script after batches of documents are successfully sent to the ingestion server. This can be useful if you need to log information about documents that were processed, for monitoring and reporting purposes.

To configure the file name of the Lua script to run, set the `IngestBatchActions` configuration parameter in the connector's configuration file.

- To run the script for all batches of documents that are ingested, set the parameter in the `[Ingestion]` section.

- To run the script for batches of documents retrieved by a specific task, set the parameter in the `[TaskName]` section.

  NOTE:

  If you set the parameter in a `[TaskName]` section, the connector does not run any scripts specified in the `[Ingestion]` section for that task.

For example:

    [Ingestion]
    IngestBatchActions0=LUA:./scripts/myScript.lua

For more information about this parameter, refer to the Confluence REST Connector Reference.

The Lua script must have the following structure:

    function batchhandler(documents, ingesttype)
       ...
    end

The `batchhandler` function is called after each batch of documents is sent to the ingestion server. The function is passed the following arguments:

Argument | Description
--- | ---
`documents` | A table of document objects, where each object represents a document that was sent to the ingestion server. A document object is an internal representation of a document. You can modify the document object and this changes the document. However, as the script runs after the documents are sent to the ingestion server, any changes you make are not sent to CFS or IDOL.
`ingesttype` | A string that contains the ingest type for the documents. The `batchhandler` function is called multiple times if different document types are sent.

For example, the following script prints the ingest type (`ADD`, `DELETE`, or `UPDATE`) and the reference for all successfully processed documents to `stdout`:

    function batchhandler(documents, ingesttype)
         for i,document in ipairs(documents) do
             local ref = document:getReference()
             print(ingesttype..": "..ref)
         end
     end

© Copyright 2019 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm