We are having an issue with the azure search results that we are receiving, we have set a filter to only retrieve the current language as per the Habitat example code, i.e.

queryable = queryable.Filter(item => item.Language.Equals(Context.Language.Name));

However that is performing a wildcard search rather then the strings having to be equal, what I mean by that is that with the Language Name being "en", we receive results for "en", "en-AU", "en-UK", en-GB". This is causing us issues as you can imagine.

We have done a fair amount of digging and we can see that the query generated from our code base has the language restriction as a search query.


We have also determined that if we had that as a filter instead it works as expected

&$filter=language_1 eq 'en' &queryType=full

Does anybody have some insight into why this is happening and how we can go about getting our desired result, as we have run out of ideas.

Thanks, Henry

1 Answer 1


Well. Some.

So the Support reference for Azure Search states:

You must not apply queries such as StartsWith, Contains to fields that contain paths or collections of GUIDs. This is because Azure Search matches regular expression searches to single words.

And while yours is not a collection of GUIDs, I'm fairly sure the issue is the dashes contained in GUIDs, which are also contained in your language codes.

Two things don't add up however:

  1. You are not using .Contains
  2. I've found nothing in Azure Search documentation to support the claim that regex is applied unconditionally to a search word

It can be put to a test however. Write a regular expression that accurately matches en but not en-AU (I, unfortunately, am terrible at regex syntax :P) and putting that through the filter. There may be transformations happening at deeper levels of Sitecore ContentSearch that are not immediately obvious.


After re-reading the quote from above and doing some more digging into Azure Search, I now know what is meant. And unfortunately it brings us no closer to an explanation. I'm going to leave this answer in here for reference.

fields that contain paths or collections of GUIDs

This refers to the fact that Azure Search will treat expressions inside / as regular expressions. So if you had a path like /home/products/something, this would be interpreted by Azure Search as an attempt to regex.

From Lucene query syntax in Azure Search:

Regular expression search

A regular expression search finds a match based on the contents between forward slashes "/", as documented in the RegExp class.

For example, to find documents containing "motel" or "hotel", specify /[mh]otel/. Regular expression searches are matched against single words.

  • I saw the .Equals and thought the same thing. It s not one of the limitations of Azure search. But the results sure sound like its the same problem.
    – Chris Auer
    Commented Jul 19, 2017 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.