开发者

whoosh MultifieldParser field search or query parser concatenation

I'm trying to use whoosh to add search functionality to my blogapp on appengine but I don't understand some stuff.

The blogentries are indexed with title, content and status fields.

I would like to have different type of results on the public page then on the admin page but without the need to have multiple indexes.

On the frontpage I want visitors to be able to search on visible entries only on the title and content fields and in the admin I want to search also on draft entries.

Can i concatenate searches using QueryParser so I can search on multiple fields?

How could I filter on status:visible with MultifieldParser?

EDIT

didn't test it yet but i got 开发者_运维技巧an answer on the whoosh mailing list:

# 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)


I know this is not strictly an answer but Google added a full text search api similar to whoosh. Perhaps you should try it.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜