Copied to clipboard

Flag this post as spam?

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


  • Ras 62 posts 325 karma points
    Aug 11, 2023 @ 06:26
    Ras
    0

    Examine search not able to handle dashes?

    Hi! I'm working with a version 8.18.8 Umbraco site right now which has a search function on the site, but discovered a bug where the search does not handle dashes. Anytime you try to search for only "-" or anything including "-" there are simply 0 results. Is this a known bug or a known case that needs to be handled?

    Having a hard time finding what would cause this as there's currently no code specifically for handling dashes.

        if (!ExamineManager.Instance.TryGetSearcher("FacetSearcher", out ISearcher searcher))
        {
            throw new InvalidOperationException($"No searcher found with name FacetSearcher");
        }
    
        searchTerm = searchTerm.MakeSearchQuerySafe();
        var headerFields = new[] { "nodeName", "contentHeader", "cardHeader" };
        var contentFields = new[] { "content", "contentText", "contentPreamble", "cardText", "metaDescription" };
    
        var criteria = searcher.CreateQuery(null, BooleanOperation.Or);
    
        var examineQuery = criteria.Field("contentHeader", searchTerm.MultipleCharacterWildcard())
            .Or().Field("cardHeader", searchTerm.MultipleCharacterWildcard())
            .Or().Field("nodeName", searchTerm.MultipleCharacterWildcard())
            .Or().Field("cardText", searchTerm.MultipleCharacterWildcard())
            .Or().Field("content", searchTerm.MultipleCharacterWildcard())
            .Or().Field("contentPreamble", searchTerm.MultipleCharacterWildcard())
            .Or().Field("contentText", searchTerm.MultipleCharacterWildcard())
            .Or().Field("blocks", searchTerm.MultipleCharacterWildcard());
    
  • Huw Reddick 1789 posts 6199 karma points MVP c-trib
    Aug 11, 2023 @ 11:59
    Huw Reddick
    0

    it is a known case that needs to be handled as the searcher strips out hyphens

    see here https://our.umbraco.com/forum/using-umbraco-and-getting-started/101385-hyphens-in-lucene-search-examine

Please Sign in or register to post replies

Write your reply to:

Draft