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

Add better OR support for mixed indexes. #890

Closed

Conversation

davidclement90
Copy link
Contributor

@davidclement90 davidclement90 commented Jan 16, 2018

Issue : #163

This PR add better OR support.
If one backend can handle the all query, we use this backend
If not it will create one query by OR's child

Now all these queries can use indexes instead of using full-scan

g.V().or(__.has("name", "Hiro"),__.has("age", 2)));
g.V().or(__.has("name", "Totoro"),__.has("age", 2)));
g.V().or(__.has("name", "Totoro").has("age", 1),__.has("age", 2)));
g.V().or(__.and(__.has("name", "Totoro"), __.has("age", 1)),__.has("age", 2)));
g.V().has("length", P.lte(100)).or(__.has("name", "Totoro"),__.has("age", P.gte(2)))
g.V().or(__.has("name", "Totoro"),__.has("age", P.gte(2))).has("length", P.lte(100))
g.V().or(__.has("name", "Totoro"),__.has("age", 2)).order().by("age")
g.V().or(__.has("name", "Totoro"), __.has("length", P.lte(120)).order().by("length"))
g.V().or(__.has("name", "Totoro"), __.has("length", P.lte(120)).order()
.by("length")).order().by("age")
g.V().or(__.has("name", "Totoro"), __.has("length", P.lte(120))).order().by("age").limit(2)
g.V().or(__.has("name", "Totoro"), __.has("length", P.lte(120))).order().by("age")
.range(2, 3)
g.V().has("length", P.gte(130).or(P.lt(100))).order().by("age")
g.V().has("length", P.gte(80).and(P.gte(130).or(P.lt(100)))).order().by("age")

If the backend can handle not query-normal-form as Elasticsearch or Lucene, the query will use mixed indexes :
g.V().has("length", P.gte(80).and(P.gte(130)).or(P.gte(80).and(P.lt(100))))

Signed-off-by: David Clement [email protected]


Thank you for contributing to JanusGraph!

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there an issue associated with this PR? Is it referenced in the commit message?
  • Does your PR body contain #xyz where xyz is the issue number you are trying to resolve?
  • Has your PR been rebased against the latest commit within the target branch (typically master)?
  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you written and/or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE.txt file, including the main LICENSE.txt file in the root of this repository?
  • If applicable, have you updated the NOTICE.txt file, including the main NOTICE.txt file found in the root of this repository?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?
  • If this PR is a documentation-only change, have you added a [skip ci]
    tag to the first line of your commit message to avoid spending CPU cycles in
    Travis CI when no code, tests, or build configuration are modified?

Note:

Please ensure that once the PR is submitted, you check Travis CI for build issues and submit an update to your PR as soon as possible.

@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label Jan 16, 2018
@twilmes
Copy link
Contributor

twilmes commented Jan 17, 2018

Awesome @davidclement90, I will try to review over the next week.

@robertdale
Copy link
Member

Did this pass all tests? mvn clean install -Dtest.skip.tp=false

@davidclement90
Copy link
Contributor Author

Yes with 3.3.0 when 3.3.1 will be merged, I will rebase then launch these tests.

@davidclement90 davidclement90 force-pushed the betterOrSupport branch 2 times, most recently from 972c64b to 7646de6 Compare February 7, 2018 13:08
@davidclement90
Copy link
Contributor Author

Yes all normal and tp test pass in 3.3.1

@sjudeng
Copy link
Contributor

sjudeng commented Feb 9, 2018

@twilmes Are you okay with this getting merged or do you still want to take a look?

@davidclement90
Copy link
Contributor Author

I miss my rebase from master (I push the master into this branch but I suppress the commit)
Asap I will re-push the branch

@davidclement90 davidclement90 removed this from the Release v0.3.0 milestone Feb 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR is compliant with the CLA kind/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants