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
    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.

  2. Parvan
    Parvan avatar
    151 posts
    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.

    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:
    <add name="CustomSearchResult" section="Most popular" 
     type="Telerik.Search.WebControls.CustomSearchResult, App_Code" 
     description="CustomSearchResult" /> 

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

    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,
    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
    21 Oct 2004
    24 Apr 2009
    Link to this post
    Great answer! Thanks a lot.
Register for webinar
3 posts, 0 answered