How to create Jquery Suggest with Sphinx Search?
can some开发者_如何学运维 one give me an idea to build jquery Suggest with sphinx search? i am newbie with sphinx i already have my searchd run and i can make a simple search.
sorry for my bad english.
- prepare list of phrases you want to use in the suggestion list (it can be most popular phrases based on your data or just search phrases people made when they used your search)
- if you want to use Sphinx create an index with some not very low min_prefix_len (http://sphinxsearch.com/docs/current.html#conf-min-prefix-len) based on the above list of phrases. Here http://habrahabr.ru/blogs/sphinx/61807/ (use some translator to translate from russian) Andrew Aksyonoff (author of Sphinx) described another way of doing the same - using mysql fulltext search for searching and Sphinx' --buildstops feature only for building the most popular words list.
- use jquery to send request to your application on each key press, your application should make request to the index (or mysql) from point 2, i.e. once you enter 'Goo' your application will return 'Google maps', 'Google earth' etc. Ensure you use proper document ranking to obtain good results.
Use indexer and --buildstops to get a list of top words.
Import the words into a database table. (and a autoincrement column to get a unique id)
Create a sphinx index on this table - and enable min_prefix_len
Setup a script that runs the users query against this index, and looks up the full words in the database, and returns it to the Javascript client library.
精彩评论