Attributes
In Sitecore Search, every piece of content on your site is represented by a collection of attributes that contain important information about your content items. This metadata is used for performing searches, displaying results, and collecting analytics. A collection of attributes about a particular item is called an entity.
Your content items already have data that can be used by Sitecore Search to optimize and display your search results. Some of the data, such as information that is listed in a meta
tag of a website, might be metadata that is specifically tagged for SEO purposes. Other pieces of data exist in the content item itself, like a title in an h1
HTML tag or a description taken from the first paragraph of a PDF.
Some attributes are included by default during domain setup based on the default Content entity, but you must create any custom attributes required to index your data. You can view a list of attributes by clicking Administration > Domain Settings > Attributes.
After you create attributes for all of the metadata you want to be usable by Sitecore Search, you must set up a source and configure how you want to extract attribute values from the metadata of your content items.
You use the attribute editing dialog to edit existing attributes and add new ones. To open the attribute editing dialog for any existing attribute, on the Attributes tab, click the attribute in the list. The attribute editing dialog contains a series of fields and options to fill out and customize for each attribute.
You can open the attribute editing dialog for an inner attribute by clicking it in the list, on the Inner Attributes tab of the composite attribute that contains it.
Composite attributes
Composite attributes are attributes that contain other attributes, called inner attributes. Composite attributes are used to group related attributes together. For example, Search uses a composite attribute, rfk_stats, to group together attributes related to site statistics.
The inner attributes in rfk_stats are also called statistical attributes. They represent data such as 1 Day Views, 7 Days Searches, and 90 Days Clicks.
You can see which attributes are composites by viewing the Data type column in the list of attributes located on the Attributes tab in Domain Settings.
You can't add new composite attributes. You can edit existing inner attributes. You might do this, for example, if you wanted to add the option to sort by top views.
You can view the inner attributes of a composite attribute by clicking the composite attribute in the tabular list. Then, click Inner Attributes.
Scope
You can view current attributes on the Attributes tab of the Domain Settings section of the Administration page. The attributes are displayed alphabetically by display name in a tabular list. The list is searchable by Display Name and by Attribute Name using the search bar at the top. You can limit the list of attributes to only those for a certain entity by making a selection in the Entity drop-down menu.
For each attribute in this view, a scope is displayed. The following lists possible scope values:
-
Inherited - base - included in the set of the entity's base attributes.
-
Inherited - vertical - included in the set of attributes defined by the template used by the entity.
-
Overridden - included in Inherited - base or Inherited - vertical, but edited afterward by a tech admin.
-
Local - added to an entity by a tech admin.
You can view the inner attributes of a composite attribute by clicking the composite attribute in the tabular list. Then, click Inner Attributes.
Properties
You can specify attribute properties in the editing dialog. In addition to defining the type of value the attribute can accept, the following properties also control its display format, and usage:
-
Entity - the entity the attribute is associated with. This might be a standard entity such as Content, or a custom one.
-
Display Name - a descriptive name for the attribute that is displayed in the UI.
-
Attribute Name - a name for the attribute that is alphanumeric with no spaces. Separate words with an underscore (_). This name is used in API responses if the Return in API response property is enabled.
ImportantThis is the same name that you will use in the source configuration.
-
Placement - placement of the attribute in the underlying data structure. Currently, the only option available for Sitecore Search is Standard and, if your domain includes multiple locales, Locale.
-
Data Type - data type for the attribute. After you select the data type, you can optionally add a default value for the attribute.
TipThe data type you choose for the attribute affects what features the attribute can be used for. Unavailable features are greyed out on the Use For Features tab.
-
Default Value - default value for the attribute. If the crawler does not find a value for this attribute in a document, the default value is used.
-
Description - internal descriptor for the attribute. This value is only visible in the attribute editing dialog.
-
Icon - icon to represent the attribute.
-
Mark as - labels that can be switched on for the attribute. Sitecore Learned and Sitecore Computed are reserved for internal use. If Required is selected, documents without this attribute are not indexed.
-
Properties - a variety of properties that can be switched on for the attribute. Depending on the data type, some of these options might be unavailable and are greyed out.
The following list represents ways an attribute can be used. When creating a new attribute or editing an existing one, you can specify the properties you want the attribute to be used for.
-
Return in API response - select to include the attribute and its values in search results.
ImportantYou must select this property to include attribute and value in the search results.
-
Available for rules and page hard filters - select to make the attribute available for use in widget rules and page settings.
-
Available for site context - select to use the attribute to configure the context for a rule.
-
Available for Quick View (in CEC) - select to display the attribute and its associated values in the Quick view pop-up window, when previewing pages using Sitecore Search.
-
Available for ranking recipes - select to use the attribute in custom recipes
NoteThe recipe feature is not yet available to use in Sitecore Search.
-
Include in request context - select to use the attribute in API requests to narrow results.
-
Build enumeration of unique values - this is selected automatically when applicable.
When selected, all possible attribute values are available for use in Sitecore Search. For example, when building a rule, you can select an attribute value instead of having to type one in.
-
The Alias and Alias in Request URL settings are for backward compatibility only and are not relevant for new domains.
Data types and formats
When you create an attribute in Search, you assign a data type to the attribute. When you extract values for the attribute, it's important to extract values in a format Search recognizes for the designated data type.
If an extracted attribute value is in a format that's incompatible with its designated data type, Search drops the entire index document, meaning the URL won't be indexed.
The following table lists supported data types and formats for each type:
Data type |
Accepted formats |
---|---|
Integer |
Standard integer value. Example: 42 |
Double |
Standard double value. Example: 3.14159 |
Array of integers |
Array of standard integer values. Example: [1, 2, 3, 4, 5] |
Float |
Standard float value. Example: 2.718 |
Array of Float |
An array of standard float values. Example: [1.2, 3.4, 5.6] |
Boolean |
Standard Boolean value. Example: true or True |
String |
Standard string value. Example: "Hello, World!" |
Array of Strings |
Array of standard string values. Example: ["apple", "banana", "cherry"] |
GEO |
Geographical location in any of the following formats:
|
Object |
JSON object. Example: RequestResponse
|
Array of objects |
Array of JSON objects. Example: RequestResponse
|
Timestamp |
Time and date in any of the following formats:
|
Including attribute values in search results
After enabling the attribute to be returned in the API, you can configure it by clicking Administration > Domain Settings > Feature Configuration > API response.
Usually, selecting the Return in api response check box for an attribute is all you need to do to include the attribute in search results. f type float that represents a price. A value for this attribute could be something like 15.6. To display it to site visitors as a currency value, you can convert it to a string and add a currency symbol.
You set up type conversion for attributes in API responses using the following configuration options:
-
Conversion type - data type to convert attribute values to. Possible values are String, Integer, Float, and Boolean.
-
Conversion format - format to use for converted attribute values, following the Go string format convention. For example, if you enter "$%.2f" into this field, Search converts the number 14.5 to a string with a dollar sign and two decimal places, $14.50.