Configure a dynamic attribute
You can use dynamic attributes in Sitecore Search to dynamically add key-value pairs to an entity rather than defining every possible attribute for that entity. Dynamic attributes are currently enabled for filtering and faceting. For more information on how this data is structured, see The dynamic attributes object.
This walkthrough describes how to:
Create a dynamic attribute
To create a dynamic attribute:
-
On the menu bar, click Administration > Domain Settings > Attributes.
-
Click Add attribute.
-
In the Entity drop-down list, select an entity, and then enter a Display Name and Attribute Name.
-
To use dynamic attributes, you must select the type Array of objects.
-
Scroll down and select the Use As Dynamic Attribute check box.
NoteSelecting the Use As Dynamic Attribute check box automatically changes the data type to Array of objects. If you change the data type, the check box is automatically cleared.
-
To include the attribute in the API response, select the Return in Api Response check box.
-
In the Value Type drop-down list, select either String or Float. This determines the value type of the collection of dynamic attributes. You cannot have a mix of string and float values within the same dynamic attribute. If you require both float and string values, create a dynamic attribute for each type.
-
In the Use For Features section, select the Facets and/or Filters check boxes to use dynamic attributes for these features. Note that the rest of the features are unavailable for dynamic attributes.
-
Click Save > Publish.
Configure your source
After creating the dynamic attribute, you must configure your source to identify and index it.
To configure your source:
-
On the menu bar, click Sources.
-
Select your source and click Transformations.
-
Click Edit and then, next to Attribute Transformations, click New.
-
In the Attribute Name field, enter a name. This must be the same name given to the dynamic attribute that you created earlier.
-
(Optional) To use a different name for the dynamic attribute:
-
Click Add Transformation.
-
In the Transformation Type drop-down list, click rename.
-
In the New Name field, enter a name and click Save.
NoteYou must do this for each dynamic attribute you create in Domain Settings > Attributes.
-
-
Click Add Transformation.
-
In the Transformation Type drop-down list, select Dynamic Attributes and click Save.
-
Click Save > Publish to update your source.