summaryrefslogtreecommitdiff
path: root/lib/query.cc
AgeCommit message (Collapse)Author
2022-04-15fix build without sfsexpMichael J Gruber
a1d139de ("lib: add sexp: prefix to Xapian (infix) query parser.", 2022-04-09) introduced sfsexp infix queries. This requires the infix preprocessor to be built in in a way which does not require sfsexp when notmuch is built without it. Make the preprocessor throw a Xapian error in this case (and fix the build). Signed-off-by: Michael J Gruber <git@grubix.eu>
2021-09-04lib/thread-fp: factor out query expansion, rewrite in XapianDavid Bremner
It will be convenient not to have to construct a notmuch query object when parsing subqueries, so the commit rewrites the query expansion (currently only used for thread:{} queries) using only Xapian. As a bonus it seems about 15% faster in initial experiments.
2021-09-04lib/query: factor out _notmuch_query_string_to_xapian_queryDavid Bremner
When dealing with recursive queries (i.e. thread:{foo}) it turns out to be useful just to deal with the underlying Xapian objects, and not wrap them in notmuch objects.
2021-09-04lib: generate actual Xapian query for "*" and ""David Bremner
The previous code had the somewhat bizarre effect that the (notmuch specific) query string was "*" (interpreted as MatchAll) and the allegedly parsed xapian_query was "MatchNothing". This commit also reduces code duplication.
2021-09-04lib/query: generalize exclude handling to s-expression queriesDavid Bremner
In fact most of the code path is in common, only the caching of terms in the query needs to be added for s-expression queries.
2021-09-04lib/parse-sexp: parse single terms and the empty list.David Bremner
There is not much of a parser here yet, but it already does some useful error reporting. Most functionality sketched in the documentation is not implemented yet; detailed documentation will follow with the implementation.
2021-09-04lib: define notmuch_query_create_with_syntaxDavid Bremner
Set the parsing syntax when the (notmuch) query object is created. Initially the library always returns a trivial query that matches all messages when using s-expression syntax. It seems better to select the syntax at query creation time because the lazy parsing is an implementation detail.
2021-09-04lib: split notmuch_query_createDavid Bremner
Most of the function will be re-usable when creating a query from an s-expression.
2019-06-14lib: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc in the lib directory
2018-04-26lib: work around xapian bug with get_mset(0,0, x)David Bremner
At least Fedora28 triggers this Xapian bug due to some toolchain change . https://bugzilla.redhat.com/show_bug.cgi?id=1546162 The underlying bug is fixed in xapian commit f92e2a936c1592, and should be fixed in Xapian 1.4.6
2017-10-09lib: convert notmuch_bool_t to stdbool internallyJani Nikula
C99 stdbool turned 18 this year. There really is no reason to use our own, except in the library interface for backward compatibility. Convert the lib internally to stdbool.
2017-05-13build: visibility=default for library structs is no longer neededJani Nikula
Commit d5523ead90b6 ("Mark some structures in the library interface with visibility=default attribute.") fixed some mixed visibility issues with structs. With the symbol default visibility reversed, this is no longer a problem.
2017-03-22lib: make notmuch_query_add_tag_exclude return a status valueDavid Bremner
Since this is an ABI breaking change, but we already bumped the SONAME for the next release
2017-03-22lib: replace deprecated n_q_count_threads with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2017-03-22lib: replace deprecated n_q_count_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name. One or two remaining uses of the (removed) non-status returning version fixed at the same time
2017-03-22lib: replace deprecated n_q_search_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2017-03-22lib: replace n_query_search_threads with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We finally remove the deprecated API, and rename the status returning version to the simpler name. The status returning is kept as a deprecated alias.
2017-03-04lib: query make exclude handling non-destructiveDavid Bremner
We filter added exclude at add time, rather than modifying the query by count search. As noted in the comments, there are several ignored conditions here.
2017-03-04lib: centralize query parsing, store results.David Bremner
The main goal is to prepare the way for non-destructive (or at least less destructive) exclude tag handling. It does this by having a pre-parsed query available for further processing. This also allows us to provide slightly more precise error messages.
2017-01-27lib: optimize counting documentsDavid Bremner
From #xapian olly> bremner: btw, i noticed notmuch count see ms to request all the documents and then ignores them bremner> hmm. There's something funny about the way that notmuch uses matches in general iirc olly> it should be able to do: mset = enquire.get_mset (0, 0, notmuch->xapian_db->get_doccount ()); ... olly> get_matches_estimated() will be exact because check_at_least is the size of the database
2016-08-09lib: provide _notmuch_database_log_appendDavid Bremner
_notmuch_database_log clears the log buffer each time. Rather than introducing more complicated semantics about for this function, provide a second function that does not clear the buffer. This is mainly a convenience function for callers constructing complex or multi-line log messages. The changes to query.cc are to make sure that the common code path of the new function is tested.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-06-05lib: whitespace cleanupTomi Ollila
Cleaned the following whitespace in lib/* files: lib/index.cc: 1 line: trailing whitespace lib/database.cc 5 lines: 8 spaces at the beginning of line lib/notmuch-private.h: 4 lines: 8 spaces at the beginning of line lib/message.cc: 1 line: trailing whitespace lib/sha1.c: 1 line: empty lines at the end of file lib/query.cc: 2 lines: 8 spaces at the beginning of line lib/gen-version-script.sh: 1 line: trailing whitespace
2016-05-25lib: make a global constant for query parser flagsDavid Bremner
It's already kindof gross that this is hardcoded in two different places. We will also need these later in field processors calling back into the query parser.
2016-04-15Add internal functions to search for alternate doc typesDaniel Kahn Gillmor
Publicly we are only exposing the non-ghost documents (of "type" "mail"). But internally we might want to inspect the ghost messages as well. This changeset adds two new private interfaces to queries to recover information about alternate document types.
2015-10-05lib: add versions of n_q_count_{message,threads} with status returnDavid Bremner
Although I think it's a pretty bad idea to continue using the old API, this allows both a more gentle transition for clients of the library, and allows us to break one monolithic change into a series
2015-09-23lib: constify arguments to notmuch_query_get_*David Bremner
These functions are all just accessors, and it's pretty clear they don't modify the query struct. This also fixes one warning I created when I introduced status.c.
2015-09-04lib: remove use of notmuch_query_search_messages from query.ccDavid Bremner
There is not too much point in worrying about the bad error reporting here, because the count api is due for the same deprecation.
2015-08-04lib: add public accessor for database from queryDavid Bremner
This is to make it easier for clients of the library to update to the new error code returning versions of notmuch_query_search_messages
2015-03-29lib: replace almost all fprintfs in library with _n_d_logDavid Bremner
This is not supposed to change any functionality from an end user point of view. Note that it will eliminate some output to stderr. The query debugging output is left as is; it doesn't really fit with the current primitive logging model. The remaining "bad" fprintf will need an internal API change.
2015-03-13lib: make notmuch_query_count_messages explicitely exactJani Nikula
The default is actually exact if no checkatleast parameter is specified. This change makes that explicit, mainly for documentation, but also to be safe in the unlikely event of a change of default. [ commit message rewritten by db based on id:87lho0nlkk.fsf@nikula.org ]
2015-03-01lib: add new status reporting API for notmuch_query_search_{m,t}David Bremner
This at least allows distinguishing between out of memory and Xapian exceptions. Adding finer grained status codes would allow different Xapian exceptions to be preserved. Adding wrappers allows people to transition gradually to the new API, at the cost of bloating the library API a bit.
2014-01-24lib: make notmuch_threads_valid return FALSE when passed NULLDavid Bremner
Without this patch, the example code in the header docs crashes for certain invalid queries (see id:871u00oimv.fsf@approx.mit.edu)
2013-11-02query: bind queries to database objectsFelipe Contreras
The queries don't really work after a database is closed, and we would like them to be freed if the database is destroyed. Acknowledged-by: David Bremner <david@tethera.net> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2013-06-24lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_tMark Walters
Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can cover all four values of search --exclude in the cli. Previously the way to avoid any message being marked excluded was to pass in an empty list of excluded tags: since we now have an explicit option we might as well honour it. The enum is in a slightly strange order as the existing FALSE/TRUE options correspond to the new NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options so this means we do not need to bump the version number. Indeed, an example of this is that the cli count and show still use FALSE/TRUE and still work.
2013-05-13lib: add --exclude=all optionMark Walters
Adds a exclude all option to the lib which means that excluded messages are completely ignored (as if they had actually been deleted).
2013-02-15bitmap:improve memory usage using CHAR_BITS and unsigned CHARRobert Mast
Using char instead of int allows for simpler definitions of the DOCIDSET macros so the code is easier to understand and consistent with respect to memory-usage. Estimated reduction of memory-usage for bitmap about 8 times.
2012-04-07lib: change default for notmuch_query_set_omit_excludedMark Walters
2012-03-18lib: fix an exclude bugMark Walters
When the exclude tags contain a tag that does not occur anywhere in the Xapian database the exclusion fails. We modify the way the query is constructed to `work around' this. (In fact the new code is cleaner anyway.) It also seems to fix another exclusion failure bug reported by jrollins but we have not yet worked out why it helps in that case.
2012-03-18lib: Add exclude query debug outputAustin Clements
2012-03-18lib: Expose query debug output via an environment variableAustin Clements
Allow query debugging to be enabled at run-time by setting the NOTMUCH_DEBUG_QUERY environment variable to a non-empty string. Previously, enabling query debugging required recompiling, but parsed queries are often useful for tracking down bugs in situations where recompiling is inconvenient.
2012-03-02lib: Add the exclude flag to notmuch_query_search_threadsMark Walters
Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to notmuch_query_search_threads. Implemented by inspecting the tags directly in _notmuch_thread_create/_thread_add_message rather than as a Xapian query for speed reasons. Note notmuch_thread_get_matched_messages now returns the number of non-excluded matching messages. This API is not totally desirable but fixing it means breaking binary compatibility so we delay that.
2012-03-02lib: Make notmuch_query_search_messages set the exclude flagMark Walters
Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by notmuch_query_search_messages for excluded messages. Also add an option omit_excluded_messages to the search that we do not want the excludes at all. This exclude flag will be added to notmuch_query_search threads in the next patch.
2012-03-02lib: Rearrange the exclude code in query.ccMark Walters
Slightly refactor the exclude code to give the callers access to the exclude query itself. There should be no functional change.
2012-01-16lib: Add support for automatically excluding tags from queriesAustin Clements
This is useful for tags like "deleted" and "spam" that people generally want to exclude from query results. These exclusions will be overridden if a tag is explicitly mentioned in a query.
2011-11-15lib: add function to get the number of threads matching a searchJani Nikula
Add function notmuch_query_count_threads() to get the number of threads matching a search. This is done by performing a search and figuring out the number of unique thread IDs in the matching messages, a significantly heavier operation than notmuch_query_count_messages(). Signed-off-by: Jani Nikula <jani@nikula.org>
2011-05-11Mark some structures in the library interface with visibility=default attribute.Carl Worth
As of gcc 4.6, there are new warnings from -Wattributes along the lines of: warning: ‘_notmuch_messages’ declared with greater visibility than the type of its field ‘_notmuch_messages::iterator’ [-Wattributes] To squelch these, we decorate all such containing structs with __attribute__((visibility("default"))). We take care to let only the C++ compiler see this, (since the C compiler would otherwise warn about ignored visibility attributes on types).
2011-01-30Simplify _notmuch_doc_id_set_init interface.Austin Clements
Don't require the caller of _notmuch_doc_id_set_init to pass in a correct bound; instead compute it from the array. This simplifies the caller and makes this interface easier to use correctly.
2011-01-30Remove code repetition in the doc ID bitmap code.Austin Clements
Remove the repeated "sizeof (doc_ids->bitmap[0])" that bothered cworth by instead defining macros to compute the word and bit offset of a given bit in the doc ID set bitmap.
2010-12-07Optimize thread search using matched docid sets.Austin Clements
This reduces thread search's 1+2t Xapian queries (where t is the number of matched threads) to 1+t queries and constructs exactly one notmuch_message_t for each message instead of 2 to 3. notmuch_query_search_threads eagerly fetches the docids of all messages matching the user query instead of lazily constructing message objects and fetching thread ID's from term lists. _notmuch_thread_create takes a seed docid and the set of all matched docids and uses a single Xapian query to expand this docid to its containing thread, using the matched docid set to determine which messages in the thread match the user query instead of using a second Xapian query. This reduces the amount of time required to load my inbox from 4.523 seconds to 3.025 seconds (1.5X faster).