# Search box widget

## Overview

You use the built-in Next.js search widgets to display a search box and search results on your website. You use the *Search box* and *Search results* widgets to enable the users of your website to search for content.

> info **PREREQUISITES**: You created at least one search index. For more information, see [Create search indexes](https://www.progress.com/documentation/sitefinity-cms/administration-create-search-indexes).

## Place the widget on the page

You can place a *Search box* widget only inside a *Section* widget.\
To do this, perform the following:

1. Inside a column from the *Section* widget, click *Add widget here…*
2. Select the *Navigation & Search* tab.
3. Click the *SEARCH BOX* widget.\
   The widget is placed inside the selected column of the *Section* widget.
4. Click *Set where to search*.

## Search setup

1. In *Specify content to search in*, select the search index that you want to use for this search box.\
   The search index is a predefined set of search content. For example, you can create a search index that contains all news. When a user enters a search word, it is applied to all news items on your website.

   > info  **NOTE**: Next.js Search widget does not search the HTML of the page.
2. Under *Search results page*, click ![Plus sign](https://www.progress.com/documentation/sitefinity-cms/assets/a68926a8c9693accc3c0fe2e7c4abef7/plus-sign.png "Plus sign") (*Select page*) and select a page from your website that will display the search results.

   > info  **NOTE**: You can select the page where the *Search box* is located, as well as any other page.

   > important  **IMPORTANT**: You must add the Next.js *Search results* widget to the page that will display the search results.
3. In *Display suggestions after typing...*, select the minimum number of characters that the user must enter, after the search box displays search result suggestions.\
   Select between the predefined values of *None*, *2*, *3*, *4*.

   > info  **NOTE**: In the advanced settings, you can configure the which fields to use for the search suggestions.

## Boost search results

> info **PREREQUISITES**: You see the *Boost search results* section only when you are using Azure Search.

You use the *Boost search results* section to configure additional parameters for Azure Search:

* *Scoring profile*\
  Scoring profiles are part of the search index and consist of weighted fields, functions, and parameters. \
  Use scoring profiles to boost search results by customizing the way different fields are ranked.
* *Scoring parameters*\
  Scoring parameters are part of the scoring functions within a scoring profile.\
  Add scoring parameters to boost content to appear higher in the search results by specifying the parameter's name and value.

You manage the scoring profiles and parameters in the Azure portal.    For more information, see [Add scoring profiles to a search index](https://docs.microsoft.com/en-us/azure/search/index-add-scoring-profiles).

## Display settings

In *Display setting* section, you can do the following:

* Change the template\
  To change the template that the *Search box* widget uses, select the new template in the *Search box template* dropdown box.

  You must first have created a custom template.\
  For more information, see [Next.js pages and templates](https://www.progress.com/documentation/sitefinity-cms/next.js-pages-and-templates).
* Configure the widget margins\
  In *Margins*, you can choose the margins between the text and the column where it is placed.\
  Choose from the predefined values of *none*, *small*, *medium*, or *large*.

Save your changes.

## Advanced widget settings

To open the advanced settings, in the upper-right corner of the *Search box* page, click ![Settings](https://www.progress.com/documentation/sitefinity-cms/assets/f9e0e0f1112bbca28b471818ea16e8f6/settings.png "Settings") (*Advanced settings*).

* In *Label*, you can enter a specific name for this widget.  This name will be displayed in:
  * The page editor as a label for the widget
  * In the treeview with the page structure in the right pane of the page editor.
* In *CSS class*, you can enter individual CSS class for the *Search box* widget.
* In *Suggestion fields*, you can enter the fields that the search suggestion will use to suggest search results while the user types in the search box.

  > info  **NOTE**: These fields must be included in the search index that you chose for this search box.\
  > For more information, see [Create search indexes](https://www.progress.com/documentation/sitefinity-cms/administration-create-search-indexes).
* In *Display on public site for...*, you can select which user role can see the widget content when viewing the public site.
* In *Search scope*, select whether to search in all sites in the index, this site only, or what is set in the system. To see how this is set for the system, go to *Administration » Settings » Advanced » Search* and find the setting *Search in all sites in an index*.
* In *Filter expressions*, you can use filter expressions to filter the search results displayed in the frontend. This is compatible with search facets. For more information, see [Filter expressions](https://www.progress.com/documentation/sitefinity-cms/next.js-search-box-widget#filter-expressions).

## Filter expressions

> info **NOTE**: This feature is available as of Sitefinity CMS 15.4.8631 for **Azure AI Search** and **Elasticsearch**, and as of Sitefinity CMS 15.4.8640 for **Lucene**. It is compatible with search facets: search facets are applied on the filtered results. For more information about search facets, see [Search facets](https://www.progress.com/documentation/sitefinity-cms/search-facets).

In *Filter expressions*, you can create a custom filter by manually entering a filter expression in JSON format. This filter expression is a serialized hierarchical JSON structure that limits the content the *Search box* widget includes in its search results.

This filter accepts the following operators:

* `eq` - equals
* `ne` - does not equal
* `gt` - greater than, for numbers
* `lt` - less than, for numbers
* `ge` - greater than or equal, for numbers
* `le` - less than or equal, for numbers
* `any+or` - contains any of the collection
* `any+and` - contains all of the collection
* `not+(any+or)` - does not contain any of the collection
* `startswith` - starts with, for strings
* `not+(startswith)` - does not start with, for strings
* `isempty` - the collection has no values
* `isnotempty` - the collection has at least one value

> info **NOTE**: `isempty` and `isnotempty` are introduced with Sitefinity CMS 15.4.8638 and apply only to collection type properties, such as classification fields (for example, `Tags` or a custom taxonomy field). Do not use them on single-value properties.

The above filters have the following properties:

* **FieldName** maps to the name of the field in the search index.
* **Operator** maps to the logical operator.
* **FieldValue** maps to the value with which to execute the logical operation.

> info **NOTE**: The fields you use in filter expressions must be included in the search index that you chose for this search box.

### Filter examples

**Basic filter by content type**

```JSON
{
    "FieldName": "ContentType",
    "Operator": "eq",
    "FieldValue": "Telerik.Sitefinity.News.Model.NewsItem"
}
```

Only returns search results whose `ContentType` matches a specific type. Use this when the search box should surface only a single content type, such as news articles.

**Filter by URL prefix**

```JSON
{
    "FieldName": "ViewUrl",
    "Operator": "startswith",
    "FieldValue": "/blog"
}
```

Limits results to content whose URL starts with `/blog`. Ideal for section-scoped search on a multi-section site.

**Exclude a URL subtree**

```JSON
{
    "FieldName": "ViewUrl",
    "Operator": "not+(startswith)",
    "FieldValue": "/internal"
}
```

Excludes all content under `/internal` from appearing in search results.

**Filter by numeric value**

```JSON
{
    "FieldName": "Price",
    "Operator": "gt",
    "FieldValue": 0
}
```

Returns only items with a price greater than zero. Useful for product catalogs where free or unpublished items should be hidden.

**Boolean filter**

```JSON
{
    "FieldName": "IsFeatured",
    "Operator": "eq",
    "FieldValue": true
}
```

Restricts search to featured content only.

**Match any of several values**

```JSON
{
    "Operator": "OR",
    "ChildFilters": [
        { "FieldName": "Category", "Operator": "eq", "FieldValue": "Technology" },
        { "FieldName": "Category", "Operator": "eq", "FieldValue": "Science" },
        { "FieldName": "Category", "Operator": "eq", "FieldValue": "Engineering" }
    ]
}
```

Returns items in any of the three STEM categories.

**Filter by tag, collection field**

```JSON
{
    "FieldName": "Tags",
    "Operator": "any+or",
    "FieldValue": "breaking-news"
}
```

Matches items whose `Tags` collection contains the value `breaking-news`. Works with choice fields, classification fields, and any multi-value property.

**Exclude a tag**

```JSON
{
    "FieldName": "Tags",
    "Operator": "not+(any+or)",
    "FieldValue": "archived"
}
```

Excludes items tagged as `archived` from results.

**Filter by tag presence, collection field**

```JSON
{
    "FieldName": "Tags",
    "Operator": "isnotempty"
}
```

Matches only items that have at least one value in the `Tags` collection. This operator takes no `FieldValue`.

**Filter by tag absence, collection field**

```JSON
{
    "FieldName": "Tags",
    "Operator": "isempty"
}
```

Matches only items that have no values in the `Tags` collection. This operator takes no `FieldValue`.

> info **NOTE**: `isempty` and `isnotempty` are introduced with Sitefinity CMS 15.4.8638 and apply only to collection type properties, such as classification fields. Applying them to a single-value property is not supported.

**Date range filter**

```JSON
{
    "Operator": "AND",
    "ChildFilters": [
        { "FieldName": "PublicationDate", "Operator": "ge", "FieldValue": "2026-01-01T00:00:00Z" },
        { "FieldName": "PublicationDate", "Operator": "lt", "FieldValue": "2027-01-01T00:00:00Z" }
    ]
}
```

Scopes search to content published in 2026 only. The date value must be in ISO format. Supported formats include:

* `yyyy-MM-dd'T'HH:mm:ss.fffK`
* `yyyy-MM-dd'T'HH:mm:ssK`
* `yyyy-MM-dd'T'HH:mm:ss'Z'`
* `yyyy-MM-dd`

**Complex filter, AND / OR**

Use a complex filter to combine multiple conditions. The complex filter is recursive and can contain child complex filters. The `Operator` property can be `"AND"` or `"OR"`, which determines how the child filters are combined.

**Example - AND:** both conditions must be true:

```JSON
{
    "Operator": "AND",
    "ChildFilters": [
        { "FieldName": "ContentType", "Operator": "eq", "FieldValue": "Telerik.Sitefinity.News.Model.NewsItem" },
        { "FieldName": "Language", "Operator": "eq", "FieldValue": "en" }
    ]
}
```

Returns only English news articles.

**Example - OR nested inside AND:** items must match the outer condition and at least one inner condition:

```JSON
{
    "Operator": "AND",
    "ChildFilters": [
        { "FieldName": "ViewUrl", "Operator": "startswith", "FieldValue": "/products" },
        {
            "Operator": "OR",
            "ChildFilters": [
                { "FieldName": "Category", "Operator": "eq", "FieldValue": "Hardware" },
                { "FieldName": "Category", "Operator": "eq", "FieldValue": "Accessories" }
            ]
        }
    ]
}
```

Returns only products under `/products` that belong to the Hardware or Accessories category.

**Complex nesting**

```JSON
{
    "Operator": "AND",
    "ChildFilters": [
        { "FieldName": "IsFeatured", "Operator": "eq", "FieldValue": true },
        { "FieldName": "Price", "Operator": "gt", "FieldValue": 50 },
        { "FieldName": "Tags", "Operator": "any+or", "FieldValue": "premium" },
        { "FieldName": "Tags", "Operator": "not+(any+or)", "FieldValue": "archived" }
    ]
}
```

A real-world e-commerce scenario: search only shows featured, premium-priced items that are tagged `premium` but not `archived`.

## Labels & Messages

In the *Labels & Messages* section, you can do the following:

* In *Search box placeholder text*, you can enter some text to orientate the user that this is a search box.\
  For example, you can enter `Search…`.This text is only a guidance for the user and is not submitted as a search term.
* In *Search button*, enter the label foe the search button that the user clicks to submit the search keyword.

Save your changes.
