apache / apache/hugegraph

Duplicate results on outside() and not(between()) API

Open
#1,586 4 comments 0 reactions 0 assignees View on GitHub
bug gremlin
Dominant language
Java
Stars
3.2k
Forks
636
Avg merge
3d 11h
Merged PRs (30d)
14

Description

### Bug Type (问题类型)

gremlin (结果不合预期)

### Before submit

- [X] 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 [FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题

### Environment (环境信息)

- Server Version: v0.11.2
- Backend: memory
- OS: 16 CPUs, 64 G RAM, windows10 WSL
- Data Size: 200 vertices, 100 edges

### Expected & Actual behavior (期望与实际表现)

#### Expected behavior
We executed the query “g.V().has('length', not(between(423,-23)))”, and expected to get the vertices whose property ‘length’ is less than the first provided number 423 or greater than the second -23.
#### Actual behavior
In theory, the vertex which is in this range could be returned, but there should be no duplicate vertices. However, we found some of the target vertices appears more than once in the results, which would not happen in other gremlin-based graph databases in the same cases. This bug also exists on not(between()) API.
#### Example to reproduce
```
hugegraph.schema().propertyKey("length").asInt().ifNotExist().create();
hugegraph.schema().vertexLabel("rope").properties("length").nullableKeys("length").create();
hugegraph.schema().indexLabel("ropebylength").onV("rope").by("length").shard().ifNotExist().create();

GraphManager graph = hugegraph.graph();

Vertex rope1 = new Vertex("rope").property("length", 546);
Vertex rope2 = new Vertex("rope").property("length", 12368578);
Vertex rope3 = new Vertex("rope").property("length", 1);
Vertex rope4 = new Vertex("rope").property("length", 47568);

graph.addVertices(Arrays.asList(rope1, rope2, rope3, rope4));

GremlinManager gremlin = hugegraph.gremlin();

String query0 = "g.V().has('length', not(between(423,-23)))";
System.out.println("query0 : " + query0);
try {
ResultSet hugeResult = gremlin.gremlin(query0).execute();
Iterator huresult = hugeResult.iterator();
huresult.forEachRemaining(result -> {
Object object = result.getObject();
System.out.println(object);
});
} catch (Exception e) {
e.printStackTrace();
}

String query1 = "g.V().has('rope', 'length', outside(423,-23))";
System.out.println("query1 : " + query1);
try {
ResultSet hugeResult = gremlin.gremlin(query1).execute();
Iterator huresult = hugeResult.iterator();
huresult.forEachRemaining(result -> {
Object object = result.getObject();
System.out.println(object);
});
} catch (Exception e) {
e.printStackTrace();
}
```

### Vertex/Edge example (问题点 / 边数据举例)
Take `"g.V().has('length', not(between(423,-23)))"` as an example, results returned by HugeGraph are as following:
```
{id=495172332315213824, label=rope, properties={length=1}}
{id=495172332311019520, label=rope, properties={length=546}}
{id=495172332315213825, label=rope, properties={length=47568}}
{id=495172332311019521, label=rope, properties={length=12368578}}
{id=495172332315213824, label=rope, properties={length=1}}
```
It does work if we add `"dedup()"`:
```
{id=495171275698733058, label=rope, properties={length=1}}
{id=495171275698733056, label=rope, properties={length=546}}
{id=495171275698733059, label=rope, properties={length=47568}}
{id=495171275698733057, label=rope, properties={length=12368578}}
```
However, we do not need `"dedup()"` to have nonredundant results in other gremlin-based graph databases, e.g., JanusGraph:
```
result{object=v[4216] class=org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex}
result{object=v[8312] class=org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex}
result{object=v[12408] class=org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex}
result{object=v[4272] class=org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex}
```

### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.