Try our conversational search powered by Generative AI!

Autocomplete - filter suggestions based on Market


On a multisite installation running both CMS and Commerce, I am performing the following code to filter search suggestions on site ID and language:

SearchClient.Instance.Statistics().Autocomplete(query, 10, new[] { $"siteid:{SiteDefinition.Current.Id.ToString()}", $"language:{currentCulture.TwoLetterISOLanguageName}" });

However, seeing as some languages have more than one market (e.g. Dutch (nl-NL) for The Netherlands and Belgium) this results in suggestions which are meant for e.g. the (Dutch language) Belgian website are showing up on the Dutch website.

I would like to be able to filter the suggestions on market as well as site ID and language, to enable differing suggestions for (e.g.) nl-NL and nl-BE. Is there any specific method to approach this, or perhaps a workaround to separate autocomplete per market?

Thanks in advance for any help.

Jan 10, 2019 14:38

Hi William,

I am not sure that you are configuring autocomplete manually or you are using tracking searching history for autocomplete.

If you use tracking then you can add more tag for market id when doing search like this:

                (query).Track(new[] {$"marketId:{_currentMarket.GetCurrentMarket().MarketId}"});

Then you can filter search suggestions on market id as same as the way you did with site id and language:

 SearchClient.Instance.Statistics().Autocomplete(query, 10, new[] {$"marketId:{_currentMarket.GetCurrentMarket().MarketId}"});

Hope this help!

Jan 11, 2019 5:40

Thank you Binh, this was indeed the solution to our problem!

Jan 11, 2019 14:47
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.