Use Cases Requiring to Modify the Source Extension JSON Configuration

The Edit Source Extensions panel offers a JSON tab where you can see and modify the whole source extension configuration details (see JSON Tab). You can use this tab to help troubleshoot source extension configuration, but also to change the configuration.

The following table indicates specific indexing pipeline extension use cases that you can only achieve by modifying the source extension JSON configuration.

You can easily apply an extension to a source from the Coveo Cloud V2 administration console (see Applying an Extension to a Source), and then modify its JSON configuration rather than writing it from scratch.

Use case Description
Pass parameters

A good practice is to reuse indexing pipeline extensions across two or more sources to prevent creating and having to manage several similar script variants.

You may not be able to reuse an extension because the code needs information that varies from one source to another and that is not available in item metadata. In such a case, the usage of extension parameters could allow you to pass the variable information your code needs to be reusable.

In the JSON tab, you can include one or more parameters and their value such as Param1, Param2 and Value1, value2 in the following source extension configuration sample:

{
  "common": {
    "preConversionExtensions": [
      {
        "condition": "",
        "extensionId": "myorg-vwrthh2s6lw5lcibrsut7cknsu",
        "parameters": {
          "Param1": "Value1",
          "param2": "Value2"
        },
        "versionId": "",
        "actionOnError": "SKIP_EXTENSION",
        "name": "NameOfMyExtension"
      }
    ],
    "postConversionExtensions": []
  },
  "items": {}
}

In your extension python script, you can get the passed parameter values from the parameters array.

# Getting 'param1' and 'param2' parameter values passed from the source extension configuration
a = parameters['param1']
b = parameters['param2']
# Adding metadata with these values
document.add_meta_data({'extparam1':a,'extparam2':b})  
Execute a specific extension version

Each time you modify and save an extension, you create a new extension version. By default, the indeixng pipeline uses the latest extension version.

On some cases, like when you actively develop and extension, you may want to temporarily apply the "stable" version of the extension, not the very last that you saved. You can get the extension version ID value from the Extensions page (see Manage Other Extension Versions).

In the JSON tab, you can specify the versionId parameter to force to use a specific extension version:

{
  "common": {
    "preConversionExtensions": [
      {
        "extensionId": "myorg-vwrthh2s6lw5lcibrsut7cknsu",
        "parameters": {},
        "versionId": "5XSihxzII4vsirD6jUlVlDeYIkz90z5U",
        "name": "NameOfMyExtension"
      }
    ],
    "postConversionExtensions": []
  },
  "items": {}
}
Action on error

You can use the optional actionOnError parameter to specify what to do when the extension returns an error.

The following table describes the available actionOnError parameter values.

Value Action when the extension returns an error
SKIP_EXTENSION The extension is skipped for the item, as if it had never ran, and the item continues to be processed in the indexing pipeline. Default value.
REJECT_DOCUMENT

The item is rejected so it is excluded from the index.

Use this value when the extension purpose is essential to the item searchability.

Your extension modifies item permissions. If the script returns and error, you cannot garanty that the item permissions will be set correctly.

You want to ensure that you do not create a security hole by making possibly sensitive information searchable by unauthorized users. You add "actionOnError": "REJECT_DOCUMENT" to the source extension JSON configuration.

{
  "common": {
    "preConversionExtensions": [
      {
        "extensionId": "myorg-retgvf2s6lw5lcibrsut7cknsu",
        "parameters": {},
        "actionOnError": "REJECT_DOCUMENT",
        "name": "SetPermissions"
      }
    ],
    "postConversionExtensions": []
  },
  "items": {}
}