You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "guijinxin (via GitHub)" <gi...@apache.org> on 2026/01/06 14:18:06 UTC
[I] [Bug] Two query behaviors that produce the same result are inconsistent. [incubator-hugegraph]
guijinxin opened a new issue, #2929:
URL: https://github.com/apache/incubator-hugegraph/issues/2929
### Bug Type (问题类型)
gremlin (结果不合预期)
### Before submit
- [x] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 [FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
### Environment (环境信息)
- Server Version: 1.7.0
- Backend: RocksDB x nodes
- OS: 192 CPUs, 256 G RAM, Ubuntu 22.04
- Data Size: 50 vertices, 100 edges
### Expected & Actual behavior (期望与实际表现)
### Expected behavior
For the two query below, the same result should be returned:
```gremlin
g.E().has('ep4', lt(0.32696354)).and(__.hasLabel('el2')).count()
g.E().has('ep4', lt(0.32696354)).match(__.as('start1').and(__.hasLabel('el2')).as('m1')).select('m1').count()
```
### Actual behavior
+ The first query thrown a exception: ```org.apache.hugegraph.exception.NoIndexException: Don't accept query based on properties [ep4] that are not indexed in label 'el2', may not match secondary/range condition```
+ The second query returned the results normally.
+ When I executed these two queries on Janusgraph and Tinkerpop, they both returned the same results.
### Vertex/Edge example (问题点 / 边数据举例)
```javascript
```
### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
```javascript
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@hugegraph.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] Two query behaviors that produce the same result are inconsistent. [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin closed issue #2929: [Bug] Two query behaviors that produce the same result are inconsistent.
URL: https://github.com/apache/hugegraph/issues/2929
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] Two query behaviors that produce the same result are inconsistent. [incubator-hugegraph]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #2929:
URL: https://github.com/apache/incubator-hugegraph/issues/2929#issuecomment-3715041508
<!-- Answer -->
Based on everything I've found, there are currently no official plans, roadmap items, or recent work in HugeGraph to fix the inconsistent index enforcement behavior in Gremlin queries. Recent issues and pull requests do not mention this bug or any scheduled work to address it. If this changes, updates would likely appear in the repository or release notes.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5611dd41-7275-4d9a-ad6d-85d62effe72a?feedback_type=other)</sup>
[](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=github) [](https://cursor.com/link/prompt?text=Based%20on%20everything%20I%27ve%20found%2C%20there%20are%20currently%20no%20official%20plans%2C%20roadmap%20items%2C%20or%20recent%20work%20in%20HugeGraph%20to%20fix%20the%20inconsistent%20index%20enforcement%20behavior%20in%20Gremlin%20queries.%20Recent%20issues%20and%20pull%20requests%20do%20not%20mention%20this%20bug%20or%20any%20scheduled%20work%20to%20address%20it.%20If%20this%20changes%2C%20updates%20would%20likely%20appear%20in%20the%20repository%20or%20release%20notes.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20th
is%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/issues/2929)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Two query behaviors that produce the same result are inconsistent. [incubator-hugegraph]
Posted by "guijinxin (via GitHub)" <gi...@apache.org>.
guijinxin commented on issue #2929:
URL: https://github.com/apache/incubator-hugegraph/issues/2929#issuecomment-3715034160
@dosu Will this bug be fixed in the future?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Two query behaviors that produce the same result are inconsistent. [incubator-hugegraph]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #2929:
URL: https://github.com/apache/incubator-hugegraph/issues/2929#issuecomment-3714894172
<!-- Greeting -->
Hi @guijinxin! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the incubator-hugegraph team.
<!-- Answer -->
HugeGraph enforces index requirements differently depending on how filters are expressed in Gremlin. When you use a top-level `has` step (like in your first query), HugeGraph's query optimizer tries to push the filter into the backend query. If the property (like `ep4`) is not indexed, it throws a `NoIndexException` to avoid a full scan. However, when you use `match` or nest filters inside traversals (like your second query), those filters are applied after data retrieval as in-memory predicates, so the index check is bypassed and no exception is thrown—even though the logic is the same.
This difference is not documented as a feature, but is a result of how HugeGraph's query planner works: only filters directly following `g.E()`/`g.V()` are "hoisted" into the backend query and subject to index enforcement. Filters inside `match`, `and`, or similar steps are evaluated later, which is why you see inconsistent behavior between the two queries. Other graph databases like JanusGraph and TinkerPop do not enforce index requirements in the same way, which is why you get consistent results there.
If you want consistent behavior and performance, it's best to ensure that properties you filter on (especially with range or secondary conditions) are indexed, or be aware that using `match`/nested traversals may bypass index checks and lead to full scans or unexpected results. This is a known area for optimization in HugeGraph, but as of 1.7.0, this is the expected behavior given the current query planner design.
References:
- [HugeGraph query optimization and index enforcement](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java)
- [ConditionQuery and index checks](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java)
- [HugeGraph indexing discussion](https://github.com/apache/incubator-hugegraph/discussions/2739)
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2f3ea7c4-d73d-4136-8b32-6ddff3510b63?feedback_type=other)</sup>
[](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=github) [](https://cursor.com/link/prompt?text=HugeGraph%20enforces%20index%20requirements%20differently%20depending%20on%20how%20filters%20are%20expressed%20in%20Gremlin.%20When%20you%20use%20a%20top-level%20%60has%60%20step%20%28like%20in%20your%20first%20query%29%2C%20HugeGraph%27s%20query%20optimizer%20tries%20to%20push%20the%20filter%20into%20the%20backend%20query.%20If%20the%20property%20%28like%20%60ep4%60%29%20is%20not%20indexed%2C%20it%20throws%20a%20%60NoIndexException%60%20to%20avoid%20a%20full%20scan.%20However%2C%20when%20you%20use%20%60match%60%20or%20nest%20filters%20inside%20traversals%20%28like%20your%20second%20query%29%2C%20those%20filters%20are%20applied%20after%20data%20retrieval%20as%20in-memory%20predicates%2C%20so%20the%20index%20check%20is%20bypassed%20and%20no%20except
ion%20is%20thrown%E2%80%94even%20though%20the%20logic%20is%20the%20same.%0A%0AThis%20difference%20is%20not%20documented%20as%20a%20feature%2C%20but%20is%20a%20result%20of%20how%20HugeGraph%27s%20query%20planner%20works%3A%20only%20filters%20directly%20following%20%60g.E%28%29%60/%60g.V%28%29%60%20are%20%22hoisted%22%20into%20the%20backend%20query%20and%20subject%20to%20index%20enforcement.%20Filters%20inside%20%60match%60%2C%20%60and%60%2C%20or%20similar%20steps%20are%20evaluated%20later%2C%20which%20is%20why%20you%20see%20inconsistent%20behavior%20between%20the%20two%20queries.%20Other%20graph%20databases%20like%20JanusGraph%20and%20TinkerPop%20do%20not%20enforce%20index%20requirements%20in%20the%20same%20way%2C%20which%20is%20why%20you%20get%20consistent%20results%20there.%0A%0AIf%20you%20want%20consistent%20behavior%20and%20performance%2C%20it%27s%20best%20to%20ensure%20that%20properties%20you%20filter%20on%20%28especially%20with%20range%20or%20secondary%20conditions%29%20are%20i
ndexed%2C%20or%20be%20aware%20that%20using%20%60match%60/nested%20traversals%20may%20bypass%20index%20checks%20and%20lead%20to%20full%20scans%20or%20unexpected%20results.%20This%20is%20a%20known%20area%20for%20optimization%20in%20HugeGraph%2C%20but%20as%20of%201.7.0%2C%20this%20is%20the%20expected%20behavior%20given%20the%20current%20query%20planner%20design.%0A%0AReferences%3A%0A-%20%5BHugeGraph%20query%20optimization%20and%20index%20enforcement%5D%28https%3A//github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStepStrategy.java%29%0A-%20%5BConditionQuery%20and%20index%20checks%5D%28https%3A//github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java%29%0A-%20%5BHugeGraph%20indexing%20discussion%5D%28https%3A//github.com/apache/incub
ator-hugegraph/discussions/2739%29) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/issues/2929)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Two query behaviors that produce the same result are inconsistent. [incubator-hugegraph]
Posted by "LYD031106 (via GitHub)" <gi...@apache.org>.
LYD031106 commented on issue #2929:
URL: https://github.com/apache/incubator-hugegraph/issues/2929#issuecomment-3745516130
> [@dosu](https://github.com/dosu) Will this issue be fixed in the future?
哈喽请问能提供一下测试用例吗,我可以复现分析一下原因
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org