我正在尝试使用whoosh在appengine上为我的blogapp添加搜索功能,但是我不理解一些东西。在
blog条目用title
、content
和status
字段建立索引。在
我想在公共页面上有不同类型的结果,然后在管理页面上,但不需要有多个索引。在
在frontpage上,我希望访问者能够只在title
和content
字段中搜索可见的条目,并且在管理员中我也希望搜索草稿条目。在
我是否可以使用QueryParser
连接搜索,以便可以搜索多个字段?
我如何过滤状态:可见与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)
我知道这并不是一个严格的答案,但是Google添加了一个类似whoosh的全文搜索api。也许你应该试试。在
https://developers.google.com/appengine/docs/python/search/overview
相关问题 更多 >
编程相关推荐