Verity and ColdFusion – Suggestions

Feb

24

by Mike Fleming at 7:14 pm (1 Comment) ColdFusion


So I guess I have been living under a rock.  Today I came across the suggestions attribute that started shipping with ColdFusion 7.  In short, this feature will attempt to suggest better search criteria than what the user provided.  For example, if you type in "blgo" as your search criteria, it may return no results.  But using the suggestions feature it can return to you the suggested search criteria of "blog".  You can then use that to suggest this to your users (i.e. like Google does), or you could even run another search using this suggested criteria.  So far this feature has done a very good job of suggesting other search criteria.

To use this feature, when you call the cfsearch tag you provide an attribute named status.  This returns a structure with additional information on the search, one of this which is the suggestions text.  An example is below.

collection="collections"
name="qrySearch"
type="Simple"
criteria="#form.searchCriteria#"
status="strSearch"
suggestions="0">


Did you mean #strSearch.suggestedquery#

One quick work of caution.  The suggestedquery element of the status structure does not always exist.  So you must check that exists before using the element.


Categories ColdFusion | Tags:

One Response to “Verity and ColdFusion – Suggestions”

  1. Michael Evangelista

    February 24, 2009
    10:41 pm

    Interesting, thanks… I will check this out for sure.
    I’ve got a simple ‘in-site’ search system based on a google sitemaps creator, which then uses its own generated XML list of URLs on the site to crawl through, clean the html down to barebones, and index the page’s text content into a verity collection.
    It’s a tasty little system so far, but adding a function like this will surely sweeten the deal!

Leave a Reply or Return to Top