---
title: Using search filters
related:
  - https://docs.kentico.com/k8/configuring-kentico/setting-up-search-on-your-website/smart-search-syntax.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The **Smart search filter** [web part](https://docs.kentico.com/k8/developing-websites/developing-websites-using-the-portal-engine/using-and-configuring-web-parts.md) allows users to limit the range of objects that will be searched (conditional filter), or define the order of the search results. You can connect any number of filters to the **Smart search dialog** or **Smart search dialog with results**.

The behavior of the smart search filter is primarily defined by the properties described below.

> **Info:** You can find information about the other properties by clicking the help link in the corner of the web part properties dialog.

| Property                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Search dialog web part ID | Enter the **Web part control ID** of the Smart search dialog or Smart search dialog with results web part that you wish to connect to the filter.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Filter mode               | Sets the user interface type of the filter. Possible choices are:<br>Drop-down list<br>Checkboxes<br>Radio buttons<br>Text box                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Filter auto postback      | Indicates whether the search results automatically refresh (via postback) whenever a user selects a different filtering option. Not applicable when using the _text box_ **Filter mode**.<br>If you enable auto postback for a search filter, also set the **Paging mode** property to _**Postback**_ for the related _Smart search results_ or _Smart search dialog with results_ web part.                                                                                                                                                                                                         |
| Values                    | Determines the available filtering options. See the **Defining filtering options** section below for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Query name                | Allows you to create the filtering options dynamically using a query (instead of the **Values** property). Enter the full code name of the query or **Select** a query. The query must return the appropriate values depending on the type of the filter.<br>For example, for a standard conditional filter, the query needs to load three columns in the following order: _,,_<br>The following is a sample query that loads all document types as conditional filtering options:<br>` 
SELECT TOP 1000 '+classname', ClassName, ClassDisplayName 
FROM CMS_Class 
WHERE ClassIsDocumentType = 1
 ` |
| Filter clause             | Sets a clause that overrides the logical values specified for filtering options. Possible choices are:<br>**None** - no clause is added and the original logical values set for individual filtering options are used.<br>**Must** - indicates that the conditions in all filtering options must be fulfilled (adds the + symbol).<br>**Must not** - indicates that the conditions in all filtering options must not be fulfilled (adds the - symbol). Conditions are inverted compared to the _Must_ option.                                                                                        |
| Filter is conditional     | If true, the filter limits the scope of the objects that are searched (where condition). If false, the filter determines the order in which the search results are displayed (order by condition).                                                                                                                                                                                                                                                                                                                                                                                                   |

You can find examples of search filters on the sample Corporate Site on the **Examples -> Web parts -> Full-text search -> Smart search -> Smart search filter** and **Faceted search** pages.

## Defining filtering options

The most important part of configuring Smart search filter web parts is the definition of the filtering options offered to users. In most cases, you will set the options through the **Values** property of the web part. If you wish to use the **Query name** property to load the options dynamically, the rules described below also apply to the results retrieved by the query.

The format of the filtering options depends on the type of the filter.

### Conditional filters

In the case of conditional filters, define one option per line in format:

_**Index field name;Value of the field;Displayed text**_

You need to specify the logical meaning of each filtering option by adding the + or - symbol as a prefix:

| + | The search only returns objects whose value in the field matches the value specified in the second part of the filtering option's definition.     |
| - | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| - | The search **excludes** all results whose value in the field matches the value specified in the second part of the filtering option's definition. |

To create filtering options that check the values of multiple index fields, use the following syntax: _**(Field1:(Value1) OR Field2:(Value2));;Text**_

If you wish to use the same value for all fields in the condition clause, you can insert the value using the **{0}** expression: _**(Field1{0} OR Field2{0};Value;Text**_

> **Note:** When entering integer or double type fields as filter options, you need to specify the type of the value:
>
> \*+DocumentCreatedByUserID;\*\*(int)\*_53;Administrator_

**Examples:**

- ;;All
- +classname;cms.smartphone;Smartphones
- +\_created;\[{%ToSearchDateTime(CurrentDateTime.AddDays(-7))%} TO {%ToSearchDateTime(CurrentDateTime)%}];Past week
- +\_content;product;Results related to products
- +(documenttags{0} OR \_content{0});product;Results related to products
- -(issecurednode:(true) OR requiresssl:((int)1));;Exclude secured documents

### Search result order filters

When creating filters that change the order of the results (i.e. the **Filter is conditional** property is disabled), define options in the following format:

_**Index field name;;Displayed text**_

The order is determined according to the values in the specified field.

> **Info:** **Notes**:
>
> - By default, the order is ascending. To make the order descending, add the DESC keyword after the field name.
> - Use the _##SCORE##_ macro instead of the field name to order results according to their search relevance (the score order is always descending and cannot be reversed).

**Examples:**

- \##SCORE##;;Score
- documentcreatedwhen;;Creation date
- SKUPrice DESC;;Price descending

### Text box filter mode

Text box filters do not offer any selection options, so the **Values** property instead determines which index fields the system searches when a user enters an expression into the text box. You can specify multiple fields, each one on a new line. Like with standard conditional filters, the + and - symbols determine whether the search returns results that contain the text box value in the given field, or only those that do not.

For example, if a text box filter has _+DocumentTags_ in the **Values** definition, visitors can enter the names of [document tags](https://docs.kentico.com/k8/managing-website-content/working-with-documents-and-pages/tagging-documents.md) into the text box and perform a standard search. The filter modifies the retrieved results to contain only documents that are marked by the specified tags.

Use the following syntax to create OR conditions that are fulfilled if the text box value matches at least one of multiple fields: _**(Field1{0} OR Field2{0})**_

For example: _+(DocumentTags{0} OR \_content{0})_

The **{0}** expression represents the value that users type into the text box filter. The search internally converts the expression to _Field:(value)_ in the resulting condition.

> **Tip:** **Tip**: To create a text box filter that behaves like a regular search box, use +_\_content_ as the only field name.

You can also use text box filters to determine the order of the search results. In this case, disable the filter web part's **Filter is conditional** property and leave the **Values** property empty. Users can then enter the name of the field used for ordering into the text box. This scenario is not recommended for use by regular visitors on the live site.

> **Note:** In order for the filter to work correctly, the data fields used in the option definitions must be set as **Searchable** in the smart search field configuration of the given object type.
>
> You can also create filtering options for the fields that are marked as **Content** by using _\_content_ as the field name. Such conditions are fulfilled if the value is found in any of the content fields.

## Filtering without search text (Faceted search)

You can implement a faceted search based exclusively on filters. Faceted search allows users to get search results simply by selecting filtering options, without the need to enter and submit search text. To achieve this result, **Configure** the properties of the web part that you use to [display search results](https://docs.kentico.com/k8/configuring-kentico/setting-up-search-on-your-website/adding-search-functionality-to-pages.md) (_Smart search results_ or _Smart search dialog with results_) according to the following instructions:

1. Make sure that the **Search text required** property is disabled.
2. Leave the **Block field‑only search** property disabled, unless you wish to force users to use a filtering option that works with standard content fields (i.e. filtering options that have _\_content_ as their field name).
3. Enable **Search on each page load** (ensures that the web part automatically displays results whenever the page is loaded, even without input from a search dialog).
4. For additional convenience, enable the **Filter auto postback** property for your _Smart search filter_ web parts (instantly refreshes the search results after users change the filtering options).
