Jump to content
  • Advertisement
Sign in to follow this  
plywood

[web] Mimicking Google Suggest

This topic is 3001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'd like to add what I am calling an autocomplete search field on my game site, that would work very similar to Google's Suggest query input. Basically, I've looked into a few things, like the Ajax Toolkit, but I figured it couldn't hurt to start by posting here to see if there are commonly-accepted approaches to getting what I need done. Essentially, the control would work as follows: (1) It looks like a HTML text input (<input type="text"...) (2) For each character that the user keys in, an Ajax message relays that character back to the server, which adds it to the previous entries (previous typed letters) and performs a new DB query. Matching records are returned via Ajax. (3) Matching records are displayed directly underneath the text field in a select/drop-down style fashion, allowing the user to click any record and have that item populate the field My whole web architecture is PHP-based, so whatever dlls, plugins, toolkits, etc. I use have to be compatible with that. Anybody have any ideas as to where I should start or what my general approach should be? What 3rd party components I should be using? Thanks for any-and-all help here! ~plywood

Share this post


Link to post
Share on other sites
Advertisement
That's essentially how I've done it. IMHO, the JS is much easier with some 3rd party library (jQuery, Prototype, etc) but your mileage may vary.

To really mimic Google's suggestions (or most search engines) you'll want to "guess" at common words or search terms instead of just doing "t%", "th%" queries. My sites haven't had a serious DB or wide enough content spread to require much work there, but it's one you'll want to consider before it becomes a huge performance hit.

Likewise, if the user input is matching whatever you've already displayed, no need for extra queries; if only some suggestions are invalidated get X new suggestions to replace the ones that no longer apply.

Any other info you can give about the actual searching might trigger something I forgot if you run into problems, I haven't touched any of that code in a long time.

Hope that helps!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!