For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Getting Started

Getting started on searching with Umbraco Search

The fundamental purpose of Umbraco Search is to build a search experience. The ISearcher interface is your main entry point for searching.

ISearcher features multiple different approaches to search, all of which you can combine into single queries. Each of these is described below.

Indexed values

Umbraco Search indexes all relevant content properties alongside system fields like the content ID (key), name, type, and so on.

An overview of the indexed system fields is found in the system fields article.

Different Umbraco property editors yield different index value types; some yield searchable Text, some yield filterable Keyword, and some yield numeric or date field types. This is important to keep in mind when searching with Umbraco Search, because the way property values are indexed directly affects the search results.

A list of the built-in Umbraco property editors and their corresponding index value types can be found in the built-in property editors article.

Searching by query yields results where one or more fields are indexed as Text contains the search query.

MySearchService.cs
using Umbraco.Cms.Search.Core;
using Umbraco.Cms.Search.Core.Models.Searching;
using Umbraco.Cms.Search.Core.Services;

namespace My.Site.Services;

public class MySearchService(ISearcher searcher)
{
    public async Task<SearchResult> SearchByQueryAsync()
        => await searcher.SearchAsync(
            indexAlias: Constants.IndexAliases.PublishedContent,
            query: "pink"
        );
}

Search by filtering

Multiple filters can be applied in a single query, and multiple values can be defined for each filter. Umbraco Search performs an AND search between filters, and an OR search between filter values.

When applying filters, you must pay attention to the expected index value types of the fields targeted for filtering. Mismatched combinations of filters and value types will most likely yield zero results.

For example, use a TextFilter when filtering Text value types, and a KeywordFilter for Keyword value types.

Filters can be negated, in which case Umbraco Search will perform an AND NOT:

Numeric and date filters also exist in a range version - for example, the IntegerRangeFilter:

Ranges include the lower interval and exclude the upper. The example above translates into: releaseYear either between 1950 and 1959 (both inclusive) or between 1980 and 1989 (both inclusive).

Facets in search results

Umbraco Search can create facets for fields indexed as a type Keyword, Integer, Decimal or DateTimeOffset.

You must pay attention to the expected field value type when defining facets. Mismatched combinations of facets and value types will most likely yield zero facet results.

Numeric and date facets also exist in a range version - for example, the IntegerRangeFacet:

Ranges include the lower interval and exclude the upper. The example above translates into: Facets for releaseYear between 1950 and 1959 (both inclusive) and between 1980 and 1989 (both inclusive).

Sorting search results

All fields can be used for sorting (ordering) search results, and sorting can be performed across multiple fields in a single query.

Sorting by field is also tied explicitly to the field value type. Mismatched combinations of sorters and value types will yield incorrectly sorted search results.

Use the ScoreSorter to sort by search result score (relevance).

Search result pagination

Search results are paginated by using skip and take.

Searching specific content variations

By default, Umbraco Search will search only for invariant content. Use culture and/or segment to include within specific content variations.

Invariant content will automatically be included in the search result when searching for variant content.

Searching for protected content

Use the AccessContext to include protected content (that is, content with public access restrictions applied) in search results.

The AccessContext requires the ID (key) of the currently logged-in member, and accepts an optional collection of group IDs.

Umbraco Search has no knowledge of members. If public access rules are defined based on member groups, make sure to pass the group IDs alongside the member ID in AccessContext.

Last updated

Was this helpful?