willholley opened a new pull request, #4810:
URL: https://github.com/apache/couchdb/pull/4810
<!-- Thank you for your contribution!
Please file this form by replacing the Markdown comments
with your text. If a section needs no action - remove it.
Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
of code collaboration. Positive feedback is represented +1 from
committers
and negative is a -1. The -1 also means veto, and needs to be addressed
to proceed. Once there are no objections, the PR can be merged by a
CouchDB committer.
See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
## Overview
Adds a `$beginsWith` operator to selectors, with json and text index
support. This is a compliment / precursor to optimising `$regex` support as
proposed in https://github.com/apache/couchdb/pull/4776.
For `json` indexes, a $beginsWith operator translates into a key range
query, as is common practice for _view queries. For example, to find all rows
with a key beginning with "W", we can use a range `start_key="W",
end_key="W\ufff0"`. Given Mango uses compound keys, this is slightly more
complex in practice, but the idea is the same. As with other range operators
(`$gt`, `$gte`, etc), `$beginsWith` can be used in combination with equality
operators and result sorting but must result in a contiguous key range. That
is, a range of `start_key=[10, "W"], end_key=[10, "W\ufff0", {}]` would be
valid, but `start_key=["W", 10], end_key=["W\ufff0", 10, {}]` would not,
because the second element of the key may result in a non-contiguous range.
For text indexes, `$beginsWith` translates to a Lucene query on the
specified field of `W*`.
If a non-string operand is provided to `$beginsWith`, the request will fail
with a 400 / `invalid_operator` error.
## Testing recommendations
I've only tested this with json indexes so far because the dev container
doesn't have `text` index support.
A basic eunit test is added for the new `selector` support. You can run
these using `make eunit apps=mango`.
Integration tests are added to the Mango test suite, which can be run via
`make mango-test`.
## Related Issues or Pull Requests
n/a
## Checklist
- [ ] Code is written and works correctly
- [ ] Changes are covered by tests
- [ ] Any new configurable parameters are documented in
`rel/overlay/etc/default.ini`
- [ ] Documentation changes were made in the `src/docs` folder
- [ ] Documentation changes were backported (separated PR) to affected
branches
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]