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.
Property editor data in Umbraco Search
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.
Search by query (full text search)
Searching by query yields results where one or more fields are indexed as Text contains the search query.
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:
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:
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.
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.
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.
Last updated
Was this helpful?