Copied to clipboard

Flag this post as spam?

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


  • Niklas Hjelm 104 posts 125 karma points
    Nov 17, 2011 @ 11:52
    Niklas Hjelm
    0

    Examine - Search with whitespace no good

    Hi!

    I'm having some issues with whitespace and umbraco.examine.

    When I do a search for dog everything is fine

    but when I do a search for nice dog nothing works. The term "nice dog" is in my index. I've tried using both the whitespaceanalyser och the standard one and made sure that the index and the searcher match. 

    Any clues to why this is?

    Using examine version which ships with 4.7

    Thanks / Niklas

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Nov 17, 2011 @ 15:45
    Ismail Mayat
    0

    Niklas,

    Are you doing MultipleCharacterWildcard() extension method on your query search string? Also you will need to split out your search term according to space and add it to your query eg

                    if(qsValue.Contains(" "))

                    {

                        string[] terms = qsValue.Split(' ');

                        foreach (var term in terms)

                        {

                           queryToBuild = queryToBuild.Or().Field(key, term);

                        }

                    }

    Regards

    Ismail

  • Niklas Hjelm 104 posts 125 karma points
    Nov 17, 2011 @ 16:20
    Niklas Hjelm
    0

    Hi Ismail

    Thanks for your reply. No I'm not using a wildcard. I think your code will work but I'm unsure how to implement it in my razor solution. Could you have a look?

     

      var searchString = Request["searchstring"];
     
      if (!String.IsNullOrEmpty(searchString))
      {
        var searchProvider = ExamineManager.Instance.DefaultSearchProvider.Name;
        var searchResults = ExamineManager.Instance.SearchProviderCollection[searchProvider].Search(searchString, true);

      
       foreach (var node in searchResults.Take(100))
        {
         <li> <span>@node.Fields["nodeName"]</span>

    }

    }

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Nov 17, 2011 @ 16:47
    Ismail Mayat
    0

    searchString. MultipleCharacterWildcard() you will need using statement for it cant remember which one it is but one of

        using Examine;

        using Examine.LuceneEngine.SearchCriteria;

        using Examine.Providers;

        using Examine.SearchCriteria;  

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft