episerver / Foundation

Foundation offers a starting point that is intuitive, well-structured and modular allowing developers to explore CMS, Commerce, Personalization, Search and Navigation, Data Platform and Experimentation.
https://docs.developers.optimizely.com/digital-experience-platform/docs/optimizely-foundation-demo-sites
Apache License 2.0
131 stars 135 forks source link

Add language aware DidYouMean functionality #944

Open zbepi opened 11 months ago

zbepi commented 11 months ago

It would be great to have language awareness in the stats call to Find for DidYouMean functionality.

return new ProductSearchResults 

{                 ProductViewModels = CreateProductViewModels(result, currentContent, filterOptions.Q),                 FacetGroups = GetFacetResults(filterOptions.FacetGroups, facetQuery, selectedfacets),                 TotalCount = result.TotalMatching,                 *DidYouMeans = string.IsNullOrEmpty(filterOptions.Q) ? null : result.TotalMatching != 0 ? null : _findClient.Statistics().GetDidYouMean(filterOptions.Q),*                 Query = filterOptions.Q,             } 
; 

The request url produced: http://127.0.0.1:8000/kRwa9aF5uXgqvMPFpDh5LHufInfCuWps/tedd_index74640/_didyoumean?query=cucumber responds with

{"status":"ok","hits":[
{"suggestion":"shoes","type":"editorial"}
]}

however, if tags with language are appended to the url, only the relevant results are returned: http://127.0.0.1:8000/kRwa9aF5uXgqvMPFpDh5LHufInfCuWps/tedd_index74640/_didyoumean?query=cucumber&tags=language:sv results with

{"status":"ok","hits":[
{"suggestion":"shoes","type":"editorial"}
]}

It would be good for clients to have examples of this.

Related jira: FIND-11732 (internal to Opti)

telleluy commented 10 months ago

Addition to Zachs comment: To add tags to the query, parameters must be appended to the GetDidYouMean call. Like: DidYouMeans = string.IsNullOrEmpty(filterOptions.Q) ? null : result.TotalMatching != 0 ? null : _findClient.Statistics().GetDidYouMean(filterOptions.Q + "&tags=language:en"),

(do not add the tags hardcoded, written like that for clarity)