Search: wordsMode (Any Word or All Words) doesn't work,

Posted by Community Admin on 04-Aug-2018 14:54

Search: wordsMode (Any Word or All Words) doesn't work, but I need it

All Replies

Posted by Community Admin on 26-Dec-2013 00:00

I posted this as a bug in the Bugs/Issues forum, but I need help with search results honoring the "AllWords" and "AnyWord" enums (0 and 1, respectively).  Since the WordsMode property is not exposed in either the SearchBox or SearchResults widgets and the wordsMode querystring parameter has no effect, I assume I need to deal with this in my custom SearchBox and/or SearchResults class.  I'm already filtering/searching a Module Builder content type by multiple fields, including a custom hierarchical taxonomy and by distance (using Geolocation API), but I don't see how to make "All Words" and "Any Word" work. Since the WordsMode property is never passed to the BuildSearchQuery method, I assume this property is unused.  I'm looking for the "magic" in the Search assemblies, but would appreciate any insight into what I'd need to override to enable the any/all words search modes.

Posted by Community Admin on 26-Dec-2013 00:00

Work around found.
Use a custom SearchBox widget/class to allow selection of wordsMode and pass its value in the querystring.  Use a custom SearchResults widget/class and override the InitializeControls method to retrieve the WordsMode from the querystring then modify a copy (keeping the original) of the query  passed from the SearchBox to include "AND" (for All Words mode)  or "OR" (for Any Word mode) between each pair of terms in the original query. Pass the "modified" query to the BuildSearchQuery method and you have correct Any/All Word results. Keeping the original query relieves you of having to remove the ANDs or ORs from the ResultsStats message.

However, if anyone knows of how I can get WordsMode to work organically within Sitefinity without my workaround, I'd appreciate it.

This thread is closed