aboutsummaryrefslogtreecommitdiff
path: root/lib/parse-sexp.cc
AgeCommit message (Collapse)Author
2025-08-09lib: return NOTMUCH_STATUS_OPERATION_INVALIDATED where appropriateAnton Khirnov
The overall goal is to allow clients to restart operations in situations where that is the response recommended by the underlying Xapian library. Amended-by: db, added above explanation
2024-07-25lib: thread-safe s-expression query parserKevin Boulain
Follow-up of 6273966d, now that sfsexp 1.4.1 doesn't rely on globals anymore by default (https://github.com/mjsottile/sfsexp/issues/21). This simply defers the initial query generation to use the thread-safe helper (xapian_query_match_all) instead of Xapian::Query::MatchAll.
2022-09-03lib: factor out lastmod range handling from sexp parser.David Bremner
This will permit the re-use of the same logic in the infix query parser. The location of the shared code in the infix side is for consistency with the other shared parsing logic. It will make more sense when a Xapian field processor is added for the lastmod prefix.
2022-09-03lib/sexp: provide relative lastmod queriesDavid Bremner
Test the relatively trivial logic changes for the sexp query parser first before refactoring that logic to share with the infix query parser.
2022-07-01lib/sexp: add parameter expansion for regex and wildcardDavid Bremner
Fix the bug reported at [1]. The parameter expansion for regex and wildcard modifiers has to be done a bit differently, because their arguments are not s-expressions defining complete Xapian queries. [1]: id:87o7yxqxy6.fsf@code.pm
2022-06-25lib/sexp: allow * as alias for "" in range searches.David Bremner
It can be tedious to use "" inside of a string, e.g. in a shell script.
2022-06-25lib/sexp: special case "" as an argument in lastmod ranges.David Bremner
Support this syntax for constincy with (data from to) ranges.
2022-01-27lib: strip trailing '/' from pathnames (sexp queries).David Bremner
This changes makes the sexp query parser consistent with the infix one in ignoring trailing '/'. Here we do a bit better and ignore any number of trailing '/'.
2022-01-26lib/parse-sexp: handle lastmod queries.David Bremner
This particular choice of converting strings to integers requires C++11.
2022-01-26lib/parse-sexp: support actual date queries.David Bremner
The default argument processing overlaps somewhat with what is already done in _notmuch_date_strings_to_query, but we can give more specific error messages for the s-expression context. The extra generality of _sexp_parse_range will be useful when we implement additional range prefixes (at least 'lastmod' is needed).
2022-01-26lib/parse-sexp: support zero argument date queriesDavid Bremner
These are not too practical, although they may simplify some user query generation code. Mainly this adds a new prefix keyword to the parser.
2021-09-04lib/parse-sexp: apply macrosDavid Bremner
Macros implement lazy evaluation and lexical scope. The former is needed to make certain natural constructs work sensibly (e.g. (tag ,param)) but the latter is mainly future-proofing in case the DSL is is extended to allow local bindings. For technical background, see chapters 6 and 17 of [1] (or some other intermediate programming languages textbook). [1] http://cs.brown.edu/courses/cs173/2012/book/
2021-09-04lib/parse-sexp: thread environment argument through parserDavid Bremner
No functionality change, just an extra argument carried everywhere.
2021-09-04lib/parse-sexp: support saved s-expression queriesDavid Bremner
It turns out there is not really much code in query-fp.cc useful for supporting the new syntax. The code we could potentially factor out amounts to calling notmuch_database_get_config; both the key construction and the parsing of the results are specific to the query syntax involved.
2021-09-04lib/parse-sexp: handle saved queriesDavid Bremner
This provides functionality analogous to query: in the Xapian QueryParser based parser. Perhaps counterintuitively, the saved queries currently have to be in the original query syntax (i.e. not s-expressions).
2021-09-04lib/parse-sexp: parse user headersDavid Bremner
One subtle aspect is the replacement of _find_prefix with _notmuch_database_prefix, which understands user headers. Otherwise the code mainly consists of creating a fake prefix record (since the user prefixes are not in the prefix table) and error handling.
2021-09-04lib/parse-sexp: support infix subqueriesDavid Bremner
This is necessary so that programs can take infix syntax queries from a user and use the sexp query syntax to construct e.g. a refinement of that query.
2021-09-04lib/parse-sexp: expand queriesDavid Bremner
The code here is just gluing together _notmuch_query_expand with the existing sexp parser infrastructure.
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/parse-sexp: support regular expressionsDavid Bremner
At least to the degree that the Xapian QueryParser based parser also supports them. Support short alias 'rx' as it seems to make more complex queries nicer to read.
2021-09-04lib/parse-sexp: handle unprefixed terms.David Bremner
This is equivalent to adding the same field name "" for multiple prefixes in the Xapian query parser, but we have to explicitely construct the resulting query.
2021-09-04lib/parse-sexp: add '*' as syntactic sugar for '(starts-with "")'David Bremner
Users that insist on using a literal '*' as a tag, can continue to do so by quoting it when searching.
2021-09-04lib/parse-sexp: 'starts-with' wildcard searchesDavid Bremner
The many tests potentially overkill, but they could catch typos in the prefixes table. As a simplifying assumption, for now we assume a single argument to the wildcard operator, as this matches the Xapian semantics. The name 'starts-with' is chosen to emphasize the supported case of wildcards in currrent (1.4.x) Xapian.
2021-09-04lib/parse-sexp: add term prefix backed fieldsDavid Bremner
We use "boolean" to describe fields that should generate terms literally without stemming or phrase splitting. This terminology might not be ideal but it is already enshrined in notmuch-search-terms(7).
2021-09-04lib/parse-sexp: support phrase queries.David Bremner
Anything that is quoted or not purely word characters is considered a phrase. Phrases are not stemmed, because the stems do not have positional information in the database. It is less efficient to scan the term twice, but it avoids a second pass to add prefixes, so maybe it balances out. In any case, it seems unlikely query parsing is very often a bottleneck.
2021-09-04lib/parse-sexp: support subject fieldDavid Bremner
The broken tests are because we do not yet handle phrase searches.
2021-09-04lib/parse-sexp: support and, not, and or.David Bremner
All operations and (Xapian) fields will eventually have an entry in the prefixes table. The flags field is just a placeholder for now, but will eventually distinguish between various kinds of prefixes.
2021-09-04lib/parse-sexp: stem unquoted atomsDavid Bremner
This is somewhat less DWIM than the Xapian query parser, but it has the advantage of simplicity.
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.