+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Search wordsMode parameter does not affect search results

Search wordsMode parameter does not affect search results

4 posts, 0 answered
  1. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    26 Dec 2013
    Link to this post
    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.
  2. Ivan A. Petrov
    Ivan A. Petrov avatar
    8 posts
    Registered:
    09 Sep 2013
    31 Dec 2013
    Link to this post
    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
  3. Daren
    Daren avatar
    5 posts
    Registered:
    26 Jun 2012
    14 Mar 2014 in reply to Ivan A. Petrov
    Link to this post

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

  4. Ivo
    Ivo avatar
    1 posts
    Registered:
    24 Sep 2012
    19 Mar 2014
    Link to this post
    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
     
4 posts, 0 answered