whoosh MultifieldParser字段搜索或查询解析器连接

asc*_*d00 6 python google-app-engine filter whoosh

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

blogentries用和title,content以及status字段索引.

我希望在公共页面上有不同类型的结果,然后在管理页面上,但不需要有多个索引.

在首页上,我希望访问者只能在和字段上搜索可见条目,在管理员中我也要搜索草稿条目.titlecontent

QueryParser我可以使用连接搜索,以便搜索多个字段吗?
我怎么能在过滤状态:可见MultifieldParser

编辑

没有测试它但我在嗖嗖的邮件列表上得到了答案:

# 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)
Run Code Online (Sandbox Code Playgroud)

Pao*_*llo 0

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

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