Write Lua Scripts

A Lua script that is run by CFS must have the following structure:

Copy
function handler(document)
...
end

The handler function is called for each document and is passed a document object. The document object is an internal representation of the document being processed. Modifying this object changes the document.

To continue processing the document, the handler function must return true. If the function returns false, the document is discarded.

A Lua script can terminate due to an error, for example if you use the Lua error function or call a Lua function that causes an error. If this happens, CFS continues to process the document, but places an error message in the ImportErrorDescription field.

After you have written a Lua script, you must set up an import task or index taskClosed A processing task run by CFS on documents. Update-index tasks run when a document's metadata (but not its content) is updated. Delete-index tasks run when a document is deleted from a repository. to run it. Import tasks and index tasks are defined in the CFS configuration file.