Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a auto suggestion search in python?

How to write a database driven auto-suggestion search using python, mysql and jquery? Are there any relevant tutorials. Because Googling just gave me several results for PHP but not anything relevant to Python.

like image 633
user426795 Avatar asked Nov 30 '25 15:11

user426795


2 Answers

There is a nice jQuery plugin for this, http://docs.jquery.com/Plugins/autocomplete. To use your data with it, you need to write a controller in python that returns the autocomplete data as a JSON structure.

You also need to pick a good framework for writing the actual controller in, check this question for some good suggestions: Recommendations of Python REST (web services) framework?

like image 194
Joakim Lundborg Avatar answered Dec 03 '25 04:12

Joakim Lundborg


Auto complete is generally implemented in a similar manner to spell checkers. Here's an article from Nick's Blog about Levenshtein Autonoma. It's written in python so you can follow along. I said generally before because while this will do spell checking and suggest similar names, it fails at anticipating where the popular queries are being done. For that, a naive approach would be a binary search tree where you've weighed the nodes based on the popularity of their search.

like image 44
wheaties Avatar answered Dec 03 '25 03:12

wheaties



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!