开发者

Personalized auto-complete

I want to implement autocomplete (auto-suggestion) - when a used start typing a word, suggestions pop up.

I want to be able to render the list of suggestion based on the user who asked for them.

For example, I have a list of books and I know for each user what books he read, liked and what language he reads. I want the autosu开发者_运维技巧ggest to be able to give a list of suggestions filtered only to books the user will like, and in his language and ranked according to his taste.

Anyone got an idea for a data structure appropriate for this ? Most auto complete algorithms use trees, but I don't want to use a personal data structure for each user since it will be very resources consuming to maintain.


Use a database (e.g., MySQL) of books with their attributes, like language:French, type:mystery, author:Jean-Claude, and so forth. User preferences for books could be in a companion database, or the user could select from select options on the web page.

On a web page, use the jQuery UI Autocomplete widget. Use the data: option to pass the users book preferences to a php query manager that creates a custom query, for example, language:French, type:mystery, author:Jean-Claude, triggers the query in MySQL, and returns the book titles with those attributes, via JSON, to the web page. The Autocomplete creates a drop down box and the user can select from it.

Many people use this architecture, or a variant of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜