Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Lee 6 posts 96 karma points
    Aug 25, 2021 @ 19:50
    William Lee
    0

    Examine CreateQuery with GroupedOr: problems with accents

    I have a field that is a multiple option dropdown with some options containing words with french accents. Ex: ["Éducation Préscolaire", "Garde Scolaire"]

    When I run code that uses Examine search with GroupedOr on the field for "Éducation Préscolaire", the search returns nothing.

    However running ExternalIndex search in the backoffice for "Éducation Préscolaire" returns the expected results and more confusingly the code search now returns the expected results until the server is reset or I rebuild the project.

    Here's a simplified code snippet of the Examine search

    if (ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index))
    { 
        var filterGrades = ["Éducation Préscolaire"]; //This returns empty result.  While  ["Garde Scolaire"] returns expected results.
        var searcher = index.GetSearcher();
        var onlineResources = searcher.CreateQuery("content")
            .ParentId(postModel.ContentId)
            .And().GroupedOr(new[] { "resourceGrade" }, filterGrades);  
    
        var contentChildren = onlineResources.Execute().Select(s => Umbraco.Content(s.Id));  
    }
    

    I'm guessing that once I run the backoffice search the Examine result is cached and the code search is able to get the correct result from that cache. But how is it that searches for options without accents work normally?

Please Sign in or register to post replies

Write your reply to:

Draft