Copied to clipboard

Flag this post as spam?

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


  • mmmoustache 50 posts 79 karma points
    Apr 03, 2012 @ 18:25
    mmmoustache
    0

    Examine: errors with erroneous space characters

    Hi All,

    I've implemented a simple examine search into my Umbraco site using razor and I'm having issues with the space character. Whenever there is a space before or after a search term (i.e. " hello" or "hello " instead of just "hello", the script errors with the message:

    Error loading Razor Script SearchResults.cshtml
    Supplied string is null or empty. Parameter name: s


    Whenever a multiple keyword search is entered it's absolutely fine however, it's just with the unnecessary spaces ("hello world" works fine) that the script errors. The same thing also happens when an empty search term is submitted (I've combatted this with jQuery but it would be good to cut it off at the source). 

    Here is the backbone of the script I'm working with:

    @{
        var term Request["searchTerm"];
      
        var criteria ExamineManager.Instance.SearchProviderCollection["SiteSearcher"]
          .CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
        Examine.SearchCriteria.IBooleanOperation filter null;
      
        var fields new string["bodyText""nodeName"};
      
        foreach (var in term.Split(' '))
        {
          if (filter == null )
          {
            filter criteria.GroupedOr(fieldst);
          }
          else
          {
            filter filter.Or().GroupedOr(fieldst);
          }
        }
    }

    Am I missing something from this script or is there different area I need to look into?

    Kind Regards,
    mmmoustache

Please Sign in or register to post replies

Write your reply to:

Draft