Skip to content

fix(server): fix match no index#3039

Open
LegendPei wants to merge 3 commits into
apache:masterfrom
LegendPei:fix/fix-match-no-index
Open

fix(server): fix match no index#3039
LegendPei wants to merge 3 commits into
apache:masterfrom
LegendPei:fix/fix-match-no-index

Conversation

@LegendPei
Copy link
Copy Markdown

@LegendPei LegendPei commented May 26, 2026

Purpose of the PR

This PR fixes a NoIndexException triggered by match() traversals when preceding has() filters contain index-required predicates such as neq() or range predicates but the related properties are not indexed.

In this case, HugeGraph extracted these filters into HugeGraphStep and pushed them into backend ConditionQuery, causing backend index validation to reject the traversal before TinkerPop could evaluate the filters normally.

Main Changes

  • Avoid extracting HasStep filters into HugeGraphStep when:

    • the following traversal step is match(), and
    • the has() predicate contains neq, gt, gte, lt, or lte.
  • Keep those filters in the traversal so they are evaluated by the normal TinkerPop filter path instead of being forced into backend index query planning.

  • Add a regression test covering the match() + no-index condition scenario from [Bug] NoIndexException triggered by match()-step #2936.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb -Dtest=CountStrategyCoreTest#testMatchWithNoIndexConditionMatchesDirectTraversal -DfailIfNoTests=false
    • mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb -Dtest=CountStrategyCoreTest -DfailIfNoTests=false

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels May 26, 2026
@imbajin imbajin requested a review from Copilot May 30, 2026 09:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes #2936 — a NoIndexException raised when leading has(...) filters using index-required predicates (neq, gt, gte, lt, lte) precede a match() step. Previously these HasContainers were extracted into HugeGraphStep and pushed to the backend, where index validation rejected them. The fix prevents that extraction in this specific shape so TinkerPop evaluates the filter normally.

Changes:

  • In TraversalUtil.extractHasContainer(HugeGraphStep, ...), stop consuming HasSteps when the step is followed (after HasStep/NoOpBarrierStep) by a MatchStep and contains an index-required predicate.
  • Add helpers followedByMatchStep and hasIndexRequiredPredicate (with MatchStep import).
  • Add regression test testMatchWithNoIndexConditionMatchesDirectTraversal in CountStrategyCoreTest.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hugegraph-server/hugegraph-core/.../optimize/TraversalUtil.java Skip HasStep extraction into HugeGraphStep before match() when predicate requires an index.
hugegraph-server/hugegraph-test/.../core/CountStrategyCoreTest.java New schema/graph setup and regression test verifying match() no longer throws NoIndexException.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 30, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

❌ Patch coverage is 74.62687% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.63%. Comparing base (f56462a) to head (a959357).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...he/hugegraph/traversal/optimize/TraversalUtil.java 74.62% 5 Missing and 12 partials ⚠️

❗ There is a different number of reports uploaded between BASE (f56462a) and HEAD (a959357). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (f56462a) HEAD (a959357)
3 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3039      +/-   ##
============================================
- Coverage     35.94%   29.63%   -6.32%     
- Complexity      338      375      +37     
============================================
  Files           803      803              
  Lines         68053    68116      +63     
  Branches       8907     8928      +21     
============================================
- Hits          24465    20188    -4277     
- Misses        40967    45622    +4655     
+ Partials       2621     2306     -315     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] NoIndexException triggered by match()-step

2 participants