Create document and attribute transformers

Structured data like CSV, XML, and JSON, are objects or a list of objects. In Sitecore Search, you can use transformers on feed crawlers, API crawlers, advanced web crawlers, or API push sources. Transformers can access properties at the document level or those of every object in a list of objects.

There are two types of transformers:

  • Document transformer

  • Attribute transformer

Add a document transformer

Document transformers can access properties at the document level and manipulate their values before assignment.

To add a document transformer:

  1. On the menu bar, click Sources and, on the Source Settings tab, in the left pane, click Transformations.

  2. In the Transformations section, click Edit.

  3. Click Add Transformation.

  4. In the Transformer Type drop-down list, click one of the following options:

    • HTML - to transform a document using HTML functions.

    • JavaScript - to transform a document using a JavaScript function.

  5. If you select the transformer type HTML, do the following:

    • In the transformation Type drop-down list, click Escape or Unescape.

    • In the Fields field, to add a field or tag, click Add Item then, in the input field, enter a field name or a comma separated list of fields.

    • To add more fields, repeat the previous step and, when you have finished, click Save.

  6. If you select the transformer type JavaScript, do the following:

    • (Optional) In the Function Name input field, enter a function name.

    • In the JS Source code input field, add valid JavaScript code and then click Save.

  7. Click Save.

Add an attribute transformer

Attribute transformers can access the same property of every object in a list and manipulate their property values before indexing the objects as entities.

To add an attribute transformer:

  1. On the menu bar, click Sources and select a source.

  2. On the Source Settings tab, in the left pane, click Transformations.

  3. In the Transformations section, click Edit.

  4. In the Attribute Transformations section, click New.

  5. In the Attribute Name input field, enter the name of the CSV column or JSON property.

  6. In the Transformations section, click Add Transformation.

  7. In the Add Transformation dialog, in the Transformation Type drop-down list, select an option.

    For transformation type details, after selection, hover your mouse over the Transformation Type field label.

    Important

    Selecting Javascript transforms an attribute value using a JavaScript function that can access all the attribute values.

  8. For the transformation type you selected, enter values for all the required fields and click Save.

  9. Click Save.

Do you have some feedback for us?

If you have suggestions for improving this article,