fix(server): fix match no index#3039
Conversation
There was a problem hiding this comment.
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 consumingHasSteps when the step is followed (afterHasStep/NoOpBarrierStep) by aMatchStepand contains an index-required predicate. - Add helpers
followedByMatchStepandhasIndexRequiredPredicate(withMatchStepimport). - Add regression test
testMatchWithNoIndexConditionMatchesDirectTraversalinCountStrategyCoreTest.
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Purpose of the PR
This PR fixes a
NoIndexExceptiontriggered bymatch()traversals when precedinghas()filters contain index-required predicates such asneq()or range predicates but the related properties are not indexed.In this case, HugeGraph extracted these filters into
HugeGraphStepand pushed them into backendConditionQuery, causing backend index validation to reject the traversal before TinkerPop could evaluate the filters normally.Main Changes
Avoid extracting
HasStepfilters intoHugeGraphStepwhen:match(), andhas()predicate containsneq,gt,gte,lt, orlte.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
mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb -Dtest=CountStrategyCoreTest#testMatchWithNoIndexConditionMatchesDirectTraversal -DfailIfNoTests=falsemvn test -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb -Dtest=CountStrategyCoreTest -DfailIfNoTests=falseDoes this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need