TIP: Enable substring search for DNN Search

Location: BlogsAll BlogsDNN Tips    
Posted by: mamlin 6/7/2009 10:15 PM

For some reason I can't fathom, DNN Search does not perform substring searches. In this tip we'll look at the one-line tweak needed to enable this common search feature... 
  
 
Substring Search
A substring search is when you search for a subset of the characters/word/phrase you're after.  For instance, instead of searching for the term "programmers" you could increase your chances of getting results by searching for "program" which would also return results for "programs", "programmer" and "programmers".  This is how most search engines commonly work by default.  If you want a search to return results only for an exact match to your search term you generally need to do something extra to specify this behavior.
 
Strangely, DNN Search does not perform substring searches -- it always performs an "exact match" search.  This means that a search for "module" will not return results for "modules".
 
Fortunately it is easy to enable substring searches with a simple change to one line of one stored procedure.  
 
 
Stored Procedure:  GetSearchResults 
To enable substring searches we only need to change an "=" comparison to a "LIKE" comparison in the stored procdure GetSearchResults.
 
Within the WHERE clause of this procedure, the search term comparison line is as follows:
 
  AND (sw.Word = @Word)
 
To enable substring search, change the line to:
 
  AND (sw.Word LIKE '%' + @Word + '%') 

See?  Simple!  Now your search for "skin" will also return matches to "skins", "skinning", "skinmeister", etc. 
 
If you're not sure how to go about updating a stored procedure then this change may not be for you.  You really should learn a bit more about SQL and database management before attempting to alter any core DNN stored procedures.
 
 
Caution!
Unfortunately, since this is a "core" stored procedure, future DNN updates could overwrite your change and "disable" substring searches.  Make a note and be mindful to validate that substring searching is still the norm after performing any DNN version upgrades.
 
 
Another Solution for Substring Search
In case you hadn't noticed, this site has forgone the default DNN Search in favor of the free Google AJAX Search.  There are a number of advantages to doing this (as long as your site's searchable content is public).  You can read all about this option and see steps for updating your DNN skin here:  http://googleAJAXsearch.com

Permalink |  Trackback

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
You are here:  
 
>> Back to the top of the blog list...

 
        account   advanced   blog   click   cloud   code   content   create   data   different   events   example   feature   file   files   free   function   good   google   just   line   list   module   modules   need   option   page   pages   query   results   role   roles   script   search   select   settings   simple   site   skin   solution   step   tags   terms   time   user   users   value   version   want  
Minimize Google AJAX Search
 
Search ES:  
This is an example of a Google AJAX Search with asynchronous search execution for two searches.  See our blog series, 'Add Google AJAX Search to your DNN skin' for info and sample code.
 
     
Minimize Get the T-Shirt
 
Shirts by Eguana Solutions
(Be cool like us!)
 
     
Minimize Most-Commented Blogs
 
 
     

Minimize Looking for more info?
 

There are tons of helpful
posts from Eguana Solutions 
on the DotNetNuke.com forums.
  
 
Click HERE to see our posts.

 
     
Minimize Modules for Sale
 

Looking for Eguana's modules? 
We're still working on them!
  

Until ours are ready to dazzle and
amaze, you'll have to make do with
the thousands of modules already
available on SnowCovered.

 
     
Minimize Favorite Modules
 

There are many great DNN modules.
A few we highly recommend are:
 
Dynamic Registration
Total control over the user signup process.  Create custom forms, execute your own SQL, use the integrated payment processing features to assign user roles, validate USERNAMEs via AJAX and much more.  Very cool.
 
URL Master
Change to friendly URLs that really ARE friendly.  Add keywords into your page URLs for better SEO.  Create 301 redirects for individual pages.  Force visitors (and search bots) to a single domain (i.e., make everyone use the "www" version of your site's URL or vice versa).  One of the single best upgrades for any DNN site.
 
Document Exchange 5 (DMX5)
Drag-and-drop from Windows Explorer directly into the DMX file manager!  File versioning, file and folder moderation, extend user permissions down to the file level (for user groups and even for individual users).  Infinite file and file info presentation options via custom display templates.  Store files locally or remotely via UNC (i.e., can securely store files somewhere besides your web server).  Much more.
 
XMOD by DNNDev
Rock-solid form module for data collection.  From simple feedback / email forms to complex, multi-part tabbed forms.  XMOD is different from other form modules because XMOD does not create a new database table for every new form definition -- an important feature if you plan to create dozens or hundreds of forms over the life of your DNN instance!  Excellent support from the developer and an active community around this module.
 
If you desire your form module to create a new DB table for each new form definition, a great alternative to XMOD is the Dynamic Forms module from DataSprings.  Dynamic Forms offers direct DB access beyond that found in XMOD as well as an easy drag-and-drop form builder option to help you get up and running very quickly.

 
     

Login