【发布时间】:2011-08-17 06:38:01
【问题描述】:
我正在尝试使用whoosh 将搜索功能添加到我在 appengine 上的博客应用,但我不明白一些内容。
博客条目使用title、content 和status 字段进行索引。
我想在公共页面和管理页面上获得不同类型的结果,但不需要多个索引。
在首页上,我希望访问者只能在 title 和 content 字段中搜索 可见 条目,并且在管理员中我也希望在 draft 个条目。
我可以使用QueryParser 连接搜索以便搜索多个字段吗?
如何使用MultifieldParser 过滤status:visible?
编辑
还没有测试,但我在 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)
【问题讨论】:
标签: python google-app-engine filter whoosh