Query – A search query¶
Represents a search query on an opened
A query selects and filters a subset of messages from the notmuch database we derive from.
Any function in this class may throw an
NotInitializedErrorin case the underlying query object was not set up correctly.
Do remember that as soon as we tear down this object, all underlying derived objects such as threads, messages, tags etc will be freed by the underlying library as well. Accessing these objects will lead to segfaults and other unexpected behavior. See above for more details.
Creates a new query derived from a Database
This function is utilized by __init__() and usually does not need to be called directly.
Defines constants that are used as the mode in which to open a database.
- Sort by message date, oldest first.
- Sort by message date, newest first.
- Sort by email message ID.
- Do not apply a special sort order (returns results in document id order).
Set the sort order future results will be delivered in
Parameters: sort – Sort order (see
Add a tag that will be excluded from the query results by default.
This exclusion will be overridden if this tag appears explicitly in the query.
Parameters: tagname – Name of the tag to be excluded
Execute a query for threads
Execute a query for threads, returning a
Threadsiterator. The returned threads are owned by the query and as such, will only be valid until the Query is deleted.
NullPointerErrorif search_threads failed
Filter messages according to the query and return
Messagesin the defined sort order
NullPointerErrorif search_messages failed
This function performs a search and returns Xapian’s best guess as to the number of matching messages.
Returns: the estimated number of messages matching this query Return type: int
This function performs a search and returns the number of unique thread IDs in the matching messages. This is the same as number of threads matching a search.
Note that this is a significantly heavier operation than meth:Query.count_messages.
Returns: the number of threads returned by this query Return type: int