[Improve]: support negative-label property queries with complete index coverage
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 636
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 14
Description
### Feature Description (功能描述)
## Background
PR #2994 keeps queries that combine a negative label predicate with user-property
filters on the conservative no-index path. This prevents an index plan from
returning only the subset of labels that happen to have a compatible index.
## Problem
Consider:
```groovy
g.V().has(T.label, P.neq("author")).has("city", "Beijing")
```
The labels that can satisfy this query may include `person`, `fan`, and
follower. If only `person` has a `city` index, selecting that index returns
matching `person` vertices while silently omitting matching `fan` and
follower vertices.
An available partial index must never be used when it cannot produce a complete
candidate set.
## Goal
Safely support negative-label predicates combined with property filters while
preserving complete query results.
## Requirements
- Determine all schema labels that can satisfy the negative-label predicate and
- expose the queried property.
- Select an index plan only when every eligible label has compatible index
- coverage.
- When coverage is incomplete, either reject with `NoIndexException` or use an
- explicitly bounded complete-scan plan.
- Never return a partial indexed subset as the query result.
- Preserve the current behavior of pure label predicates, for example:
- `g.V().has(T.label, P.neq("author"))`.
- Cover `neq`, `NOT_IN` / equivalent flattened predicates, and multi-label
- cases where only some labels are indexed.
- Add tests that verify no eligible label is skipped and that paging/limit are
- applied only after a complete candidate set is established.
## Related
#2992
PR #2994
Contributor guide
Research direction
Start by tracing the index-planning path affected by PR #2994 and review the related context in #2992. Reproduce the negative-label query examples with indexed and unindexed labels, then add coverage for neq, NOT_IN, multi-label cases, and paging or limits. Done means no eligible label is skipped and incomplete coverage never produces a partial result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100