Use an attribute as a filter
A filter is a search component that you can use to limit the type of content and attributes you want to be returned.
Depending on your use case, filters can be visible to your visitors, or they might be used behind-the-scenes to only show a subset of results. An example of filters working behind the scenes is if you create a filter based on the blog_status attribute, and create a rule to show only blog_status=published blogs when site visitors in a specific context search for a term.
The following procedures describe how you can configure attributes as filters.
Enable an attribute for use as a filter
To enable an attribute for use as a filter:
-
On the menu bar, click Administration > Domain Settings, then click Attributes.
-
To search for the attribute you want to edit, in the search bar, enter the attribute name. Then click the attribute in the tabular list. This opens the attribute editing dialog.
TipNote the value of the attribute's Attribute Name. This might be different than the display name and is necessary for feature configuration.
-
On the Use For Features tab, select the Filters option.
-
Click Save.
-
Click Publish. Confirm the action when prompted.
Configure a filter
Marking an attribute as use for filters is usually enough to create a filter. Optionally, you can select an analyzer to use for this filter or change the filtering operator from the default Or to And.
To configure a filter:
- On the menu bar, click Administration > Domain Setting > Feature Configuration.
- Click Filters, and then next to the filter you just added, click Edit
. - In the fields, refer to the following table and provide values.
| Field | Description | Use and example |
|---|---|---|
| Filter type | Determined automatically from the attribute's data type.If the attribute's data type is numeric, the filter type defaults to Range.For all other cases, the filter type defaults to Terms. | When filter type is, values are compared as if they are numbers.Terms, values are compared as strings. |
| Multiple value operator | Determines multiple values are used when filtering.The available options are Or and And, which is the default. | And - Use this operator when you want to the result to satisfy both or all supplied filter values. For example, filteringOr - Use this operator when you want to the result to satisfy any one supplied filter values.We have books with publishers based in New York, Chicago, Toronto, and London.To filter for books published in Canada and books published in the USA, you use the And operator. The results are books with publishers based in New York, Chicago, and Toronto.To filter for books published in Canada or the UK, you use the Or operator. The results a books with publishers based in Toronto and London. |
| Analyzer | Option to use a lowercase analyzer to compare string values.The lowercase analyzer, which converts input to lowercase letters, rendering the filter case-insensitive.The default is No analyzer. | Some publications have a content type of blog and others have a content type of Blog.When filtering for publications with blog as content type include all the blogs when lowercase is selected.Results include only publications with blog as content type when No analyzer is selected. |
-
Click Save.
-
If you want changes to come into effect immediately, click Publish and confirm the action when prompted.
NoteSources have to be reindexed for domain-level changes to come into effect.
If you don't want changes to come into effect right now, clear the Reindex all sources after publishing domain settings check box before you click Publish.