The extension method is called .UsingSynonyms() in EPiServer.Find namespace.
Thanks.
My developer index does not support synonyms, grr!. I'm working on to get synonym support, but for now is it possible to check if Synomyns is supported for the index from code?
var query = (IQueriedSearch<ISearchContent, QueryStringQuery>)SearchClient.Instance.UnifiedSearchFor(q);
//Use synonyms and weights from admin
if (SearchClient.Instance.Settings.Admin)
{
query = query.UsingSynonyms().UsingUnifiedWeights();
}
For others with the same question. I had to cast the query to IQueriedSearch to be able to use the extensions UsingSynonyms and UsingUnifiedWeights. Havn't been able to test this code yet because of developer index that do not support synonyms.
Is there a way to get this working for typed search instances also or is the synonyms just for UnifiredSearch?
If you are having problems with UsingSynonyms and UnifiedSearch, make sure that you are calling UnifiedSearchFor and UnifiedSearch found in EPiServer.Find.ClientExtensions and not in EPiServer.Find.Cms.ClientExtensions.
No. As long as you invoke "For" your query should be turned into an IQueriedSearch.
SearchClient.Instance.Search<PageData>().For("Something").UsingSynonyms().GetResult()
No problem. My first answer wasn't really an answer to your question either I see now. I guess you're not the only one who need more coffee :-)
Hi Per Magne,
Is the issue from your first answer "EPiServer.Find.ClientExtensions and not in EPiServer.Find.Cms.ClientExtensions." still a problem in Find v. 12.x ?
I'm struggelig to get the synonyms and DidYouMean to work. I get best bets.
My code for synonyms:
return _client.UnifiedSearchFor(query) .BoostMatching(x => x.SearchTitle.Match(query), 2) .UsingSynonyms() .ApplyBestBets() .TermsFacetFor(x => x.SearchSection) .Filter(p => p.SearchTypeName.Match("Page")) .StaticallyCacheFor(TimeSpan.FromHours(1)) .Track() .GetResult()
My code for DidYouMean:
return _client.Statistics().DidYouMean(query, 3).Hits.Select(x => x.Suggestion).ToList();
And yes - I have added the syonyms and did you mean in the admin gui.
I think that has been fixed. Is this an an on-premise installation, by any chance?
Hi,
We are working on a multi site with many languages and I only managed to get DidYouMean to work when I configured Related Queries for a specific site and language. For all other configurations did the for "All websites" in "all languages" work. Is this a feature or a bug?
Sounds a bit like a bug to me.
However, you could try something like:
SearchClient.Instance.Statistics().DidYouMean(query, 3, ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().AddDefaultTags(null))
I too have same issue with UsingSynonyms(), I am not using UnifiedSearch. where i am getting wrong results in refined search.
when i use .UsingSynonyms() extension with multi words for eg: "Campbell College AND Farm House", getting wrong results instead of decrease the count it is increasing.
When i dont use .UsingSynonyms() extension with multi words for eg: "Campbell College AND Farm House", getting correct results.
and I do not created any Synonyms in CMS. (synonyms are empty).
The apply synonyms function works in the preview weights function in Find configuration tool. But where can I find the function in the .Net api? I think it should be something like .ApplyBestBets (.ApplySynonyms)