如何使用 python 构建交互式搜索引擎 Web 界面
我已经构建了一个静态 Web 界面,用于从 PostgreSQL 数据库中的某些表中搜索数据。查询网站由一个用于输入搜索词的简单文本字段组成,结果网站将结果显示为一个简单的 html 表格。用于搜索 PostgreSQL 数据库并返回结果的服务器端代码是使用 psycopg2 用 python 编写的。
现在我想向我的搜索引擎添加一些交互式“Ajax 功能”。当输入搜索词时,我希望能够看到可能的搜索词列表,就像谷歌那样。在结果页面上,我希望能够对显示结果的表格进行排序。
为我的搜索引擎网站实现这些功能的最简单/推荐的方法是什么?
I have build a static web interface for searching data from some tables in my PostgreSQL database. The query website consists of a simple textfield for entering the search term, the result website presents the results as a simple html table. The server side code for searching the PostgreSQL database and returning the results is written in python using psycopg2.
Now I would like to add some interactive "Ajax features" to my search engine. When entering the search term I would like to be able to see a list of possible search terms like Google does it. On the results page, I would like to be able to sort the table showing the results.
What would be the easiest/recommended way to implement these features for my search engine web site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不必在 Django 之外构建搜索,但是 Haystack http://haystacksearch.org/ 让事情变得非常简单简单的。
如果你不想了解 Django,你可以看看 Whoosh。 http://bitbucket.org/mchaput/whoosh/wiki/Home
I have not had to build a search outside of Django, but Haystack http://haystacksearch.org/ makes things very easy.
If you don't want to get into Django you could look at Whoosh. http://bitbucket.org/mchaput/whoosh/wiki/Home
您所说的“Ajax 功能”在技术上称为自动建议。除非你想重新发明轮子。我强烈建议使用 Apache Solr 为数据库表建立索引。它配备了自动建议、分面过滤(就像大多数电子商务网站一样)和拼写检查。由于它是基于 HTTP 的,因此您可以使用其 RESTful API 非常轻松地连接到 Python。
what you call "Ajax features" are technically known as auto-suggest. Unless you want to reinvent the wheel. I would highly recommend indexing your db tables using Apache Solr. It comes with autosuggest, faceted filtering (like on most ecommerce sites) and spell-check. and since it is HTTP based you can hook into Python very easily using its RESTful API.