Search wordsMode parameter does not affect search results
The "wordsMode" querystring parameter does NOT affect the search results. Whether &wordsMode=0 (All Words) or &wordsMode=1 (Any Word) is passed, the search results remain the same, when they should not. The WordsMode property is not exposed in either the SearchBox or SearchResults widgets either. Further, it seems that the WordsMode property is not even passed to the BuildSearchQuery method. In short, the search function can't distinguish searches based on "Any Word" or "All Words," because the parameter/property although present is unused.
Hello Larry,
I have tried the explained behaviour and I was able to reproduce it. I will investigate it further and consult with the developers of that functionality and will get back to you as soon as I have some new information.
Regards,
Ivan A. Petrov
Telerik
Hello.... Are there updates for this issue?
Hi Daren,
Currently the only way to get this working is to create custom widgets that derive from SearchBox and SearchResults. Into the class that derives from SearchResult you will have to override the BuildSearchQuery method regarding the SearchResult's WordsMode property.
Here is sample code for both custom widgets.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
Telerik.Sitefinity.Services.Search;
using
Telerik.Sitefinity.Services.Search.Web.UI.Public;
namespace
SitefinityWebApp
public
class
CustomSearchResult : SearchResults
protected
override
string
BuildSearchQuery(
string
searchQuery, ISearchService service)
if
((WordsMode)Enum.Parse(
typeof
(WordsMode),
this
.WordsMode) == Telerik.Sitefinity.Services.Search.Web.UI.Public.WordsMode.AllWords)
searchQuery = searchQuery.Replace(
" "
,
" AND "
);
else
searchQuery = searchQuery.Replace(
" "
,
" OR "
);
return
base
.BuildSearchQuery(searchQuery, service);
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
Telerik.Sitefinity.Services.Search.Web.UI.Public;
namespace
SitefinityWebApp
public
class
SearchBoxAnyWordMode : SearchBox
protected
override
void
InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
this
.WordsMode = Telerik.Sitefinity.Services.Search.Web.UI.Public.WordsMode.AnyWord;
base
.InitializeControls(container);