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 t in term.Split(' ')) { if (filter == null ) { filter = criteria.GroupedOr(fields, t); } else { filter = filter.Or().GroupedOr(fields, t); } } }
Am I missing something from this script or is there different area I need to look into?
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:
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:
Am I missing something from this script or is there different area I need to look into?
Kind Regards,
mmmoustache
is working on a reply...