Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use $or with a mango JSON index #1011

Closed
wants to merge 1 commit into from

Conversation

nono
Copy link

@nono nono commented Nov 20, 2017

Overview

Since #816, mango JSON index on compound fields can be selected only if the selector make sure that all the fields listed in the index are always present. This commit add a special case where all clauses of an $or can ensure that a field is present.

For instance, if I had an index:

[A, B]

is_usable would now return true for the selector:

{
  "A": "foo",
  "$or": {
    "B": "bar",
    "B": "baz"
  }
}

Testing recommendations

Run the mango test suite. Manually run some mango queries with/without JSON indexes and check that the results are as expected.

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;

Since apache#816, mango JSON index on compound fields can be selected only if
the selector make sure that all the fields listed in the index are
always present. This commit add a special case where all clauses of an
`$or` can ensure that a field is present.

For instance, if I had an index:

[A, B]

is_usable would now return true for the selector:

{
  "A": "foo",
  "$or": {
    "B": "bar",
    "B": "baz"
  }
}
@willholley
Copy link
Member

Thanks for this @nono. Would you be able to write an integration test (e.g. https://github.com/apache/couchdb/blob/master/src/mango/test/05-index-selection-test.py#L24)?

It's probably also looking at #1014 as that PR changes the implementation of has_required_fields a little and $or would be susceptible to the related bug.

@willholley willholley mentioned this pull request Dec 1, 2017
3 tasks
@willholley
Copy link
Member

fixed in #1038

@willholley willholley closed this Dec 15, 2017
@nono
Copy link
Author

nono commented Dec 15, 2017

Thanks @willholley!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants