Support reference for Azure Cognitive Search

Current version: 8.2
Caution

Azure Cognitive Search will be discontinued in the future and Sitecore will no longer provide support for this service in future releases.

This topic references the different types of support for Azure Cognitive Search, including Query support and Facet support. Read Walkthrough: Configure Azure Cognitive Search in conjunction with this reference topic.

Query support

Sitecore Azure Search provides mapping capabilities from LINQ to queries that are supported by the Microsoft Azure Cognitive Search API.

At the moment, the Azure Cognitive Search service supports two types of query syntax, Lucene and OData.

The Lucene query syntax is used for:

  • Field-scoped queries

  • Regular expression searches

  • Wildcard searches

The OData query syntax:

  • Can filter scenarios for non-searchable data types, such as int or dateTime, for example.

  • Is used for comparisons.

  • Is contained within collections.

  • Uses unary operators.

The Sitecore Azure Search provider covers most of the query scenarios available for Lucene, here are the most commonly used ones:

Query scenario

Example

Field scope searches

RequestResponse
from d in queryable where d.Name.Contains("Sitecore") select d 
from d in queryable where d.Name.Like("Sample Item") select d 
from d in queryable where d.Name == "Sample Item" select d 
from d in queryable where d.Name.Matches("Sample.*") select d

Logical operators

(including, &, Or, Not, and Between)

RequestResponse
from d in queryable where d.Name.Contains("Sitecore") && d.Price > 100 select d 
from d in queryable where d.Price.Between(1000, 2000, Inclusion.Both)select d 

Ordering

RequestResponse
from d in queryable where d.Name.Like("Sample Item") orderby d.Id select d 

Boosting

RequestResponse
from d in queryable where d.Name.Like("Sample").Boost(2f) || d.Template.Like("Sample") select d 

Searching within collections

RequestResponse
from d in queryable where d.TemplateIds.Contains(Sitecore.TemplateIDs.Layout) select d 
Important

You must not apply queries such as StartsWith, Contains to fields with of type EDM.String that contain paths (such as /sitecore/content/home) or collections of GUIDs. This is because Azure Cognitive Search matches regular expression searches to single words.

Features that are not currently supported include:

  • Joins, for example, GroupJoin, Join, SelfJoin.

  • Queries with predicates of both Lucene and OData syntax that are joined or are an operand, for example:

    RequestResponse
    from d in queryable where d.Name.Contains("Sitecore") || (d.Price > 1000) select d) 

Facets support

Sitecore Azure Search provides mapping capabilities from the Content Search facet API to queries that are supported by the Microsoft Azure Cognitive Search API.

The currently supported features include:

Feature

Example

Build facets

queryable.FacetOn(x => x.Country).GetFacets()

Build facets in a single request

queryable.FacetOn(x => x.Country).FacetOn(x => x.Brend).FacetOn(x => x.Price).GetFacets()

Filter values to facet

queryable.FacetOn(x => x.Country, null, new {"Denmark", "Germany"}).GetFacets()

Exclude terms by the minimal count of documents

queryable.FacetOn(x => x.Country, 10).GetFacet()

The query will return terms that contain more than 10 documents.

Important

You cannot use this feature to increase performance because it is only supported on the client side.

Limit the count of terms in a facet

The provider returns 10 terms per facet by default. You can set the limit in: sitecore/contentSearch/configuration/indexes/index/maxTermsCountInFacet

Note

Currently all pivot facets are not supported; they are excluded from requests and ignored.

Do you have some feedback for us?

If you have suggestions for improving this article,