Search wordsMode parameter does not affect search results

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

Search wordsMode parameter does not affect search results

All Replies

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

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.

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

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-Mar-2014 00:00

Hello.... Are there updates for this issue?

Posted by Community Admin on 19-Mar-2014 00:00

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);
        
    

In order to get the custom widgets visible into the Sitefinity Toolbox you have to register it. You can read more about this here.

Regards,
Ivo
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed