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

Forums / Developing with Sitefinity / Wildcard search

Wildcard search

3 posts, 0 answered
  1. Roger Salomonsson
    Roger Salomonsson avatar
    5 posts
    Registered:
    21 Oct 2004
    23 Apr 2009
    Link to this post
    Is there a way to automatically append an asterisk to a search phrase so that a wildcard search is always performed? If I, for example search for "bo", the search result page should display matches from pages containing both "bound" and "bolder", not only pages matching the exact phrase "bo". Can this be done without implementing a new search box and result page (i.e with SearchManager.Search)?

    I saw in web.config in the <searchInputValidation> tag, an attribute "replacementString" but I can't find any documentation for it.

    Regards,
    Roger
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    24 Apr 2009
    Link to this post
    Hello Roger Salomonsson,

    Yes - you can add automatically asterisk to the end of the searched query. The wildcard queries (using * ?) are slower than the standard queries.
    The <searchInputValidation element in the web.config is used to validate the query, by using regular expressions. Usually this configuration is not used. To enable it for a Search Result control, edit the control and set its EscapeSpecialChars to False.

    Setup:
    1. Copy the attached CustomSearchResult.cs in your site App_Code folder.
      Open and edit the web.config file.  
    2. Add this line in <toolbox> section:
    <toolboxControls> 
    ... 
    <add name="CustomSearchResult" section="Most popular" 
     type="Telerik.Search.WebControls.CustomSearchResult, App_Code" 
     description="CustomSearchResult" /> 
    </toolboxControls> 

    3. Add this rule to the <ssearchInputValidation section:
    <searchInputValidation> 
    ... 
       <add matchPattern="([\w]+)" replacementString="$1*" enabled="true"  
      matchAlert="Adds wildcard search. Wildcard search is slower!"/> 
    </searchInputValidation> 

    4. Replace your old Search Result control with the new CustomSearchResult located in the Most popular section of the toolbox. Set the EscapeSpecialChars property to False.

    Best wishes,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Roger Salomonsson
    Roger Salomonsson avatar
    5 posts
    Registered:
    21 Oct 2004
    24 Apr 2009
    Link to this post
    Great answer! Thanks a lot.
Register for webinar
3 posts, 0 answered