7

我正在尝试使用whoosh将搜索功能添加到我在 appengine 上的 blogapp 中,但我不明白一些东西。

title博客条目使用和字段content进行索引。status

我想在公共页面和管理页面上有不同类型的结果,但不需要多个索引。

在首页上,我希望访问者能够仅在和字段上搜索可见条目,并且在管理员中我还希望搜索草稿条目。titlecontent

我可以使用连接搜索,QueryParser以便可以搜索多个字段吗?
我如何过滤status:visible with MultifieldParser

编辑

还没有测试它,但我在 whoosh 邮件列表上得到了答案:

# Create a parser that will search in title and content
qp = qparser.MultifieldParser(["title", "content"], ix.schema)
# Parse the user query
q = qp.parse(user_query_string)
# If request is not admin, filter on status:visible
filterq = query.Term("status", u"visible") if not is_admin else None
# Get search results
results = searcher.search(q, filter=filterq)
4

1 回答 1

0

我知道这不是一个严格的答案,但谷歌添加了一个类似于 whoosh 的全文搜索 api。也许你应该尝试一下。

https://developers.google.com/appengine/docs/python/search/overview

于 2012-07-16T17:16:27.033 回答