Verity and ColdFusion - Suggestions

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.

<code lang="cfm[lines]"><cfsearch collection="collections" criteria="#form.searchCriteria#" name="qrySearch" status="strSearch" suggestions="0" type="Simple"></cfsearch>


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.

Comments

comments powered by Disqus