Skip to main content
Known Participant
September 17, 2012
Question

Is it possible to have one search box search many fields? ( and "autocomplete" the results)?

  • September 17, 2012
  • 1 reply
  • 1263 views

I'm really new to the whole area of JSON, autocomplete and javascript. My first project in this area is personal: making it easier to search for wines in my wine cellar.

I have all my wines in a sqlite database (driven by CF 9 of course) and have a nice UI to report on, add, modify, delete, etc.  What I want to add is a search capability that works like this:  a user types text in a search box in any order they want and automagically, the wine is found. 

To be specific, a user could start with "2005 Caymus" and the area below the text search box would be populated with all of the varietals of Caymus for 2005 that are in the cellar.   Similarly the user might start the search by typing "2005 Cabernet" in which case anything in the cellar that is from 2005 and a Cabernet Sauvignon or a Cabernet Franc from all wineries would appear below the text box. Or maybe they just want to see what French wines are in the cellar, so they'd start their search with "France" or "French". (BTW,  winery, vintage, wine type (varietal), country, appellation, etc. are all separate fields in the database/table.)

Is my imagined search capability possible, or does each aspect of the search (year, winery, wine type/varietal) have to be user-entered into a separate text box?

Any guidance/answers greatly appreciated!  If you're local, might even be worth sharing a vintage bottle of wine!

This topic has been closed for replies.

1 reply

Inspiring
September 17, 2012

The two pieces to this puzzle are searching your database with a string search parameter, and, getting query results to offer autosuggest selections. 

I suggest that you start by reading the documentation on the autosuggest attributes of cfinput and get that to work with a very simple list.  Then see what sort of query you can write.  You know your database better than any of us.

CFsolarAuthor
Known Participant
September 17, 2012

Thanks Dan. I like the way you parsed the problem.  That's what I needed...

I've explored the basics - a cfinput tag bound to a cfc that contains a query and returns JSON.  It makes sense to me and I have that working on a single text-box interacting with a single database column.  I even "get" (albeit to a lesser degree) how conceptually one text box can autosuggest for the next box.

The thing I'm unclear about is how to make a single text box more free-form...more "google-esque" if you will where the user input can be less structured.  Does this only exist for search giants with an army of engineers or are there pieces an individual can cobble together to get a similar result.

Inspiring
September 17, 2012

I don't understand what you mean by making a single text box more free-form.