简体   繁体   中英

MySQL search autocomplete like Amazon

This question may seem naive. I don't want to reach the power of this big company with me alone.

The question: when you go to http://www.amazon.com try to search for "harry potter" but instead type: "hary poter".

You will see a result like:

  • harry potter
  • harry potter in Books
  • harry potter in Movies & TV

And the question is, I have a huge MySQL database with products. How to implement such a search result on it?

I know Apache Lucene, but I want to know if there are simpler approaches.

1) record search terms submitted / use your current database - resturucture the data to optimize keyword searches

2) add an onkeyup handler to send an Ajax request serverside (but use a mutex so you only have one call outstanding at a time)

3) serverside do a keyword lookup against the data from 1 and return the matchnig data

4) when the ajax call returns add the rows as a clickable entries in a div in a new layer

What's so difficult about that? You can use any type of database you like. You can use any serverside programming language you like. Browserside you should probably stick to javascript.

(If you want someone to write the code for you, then you'll probably need to pay them)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM