[Bug] 查询a属性边得到b属性的边
- 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: 8 CPUs, 32 G RAM, win10 wsl
- Data Size: 40w vertices,440w edges
### Expected & Actual behavior (期望与实际表现)
# Expected:
Query : g.V().has('Person', 'id', 933).bothE('knows').limit(3) return edges with label 'knows'.
# Actual:
{id=S1:2Ea>10>>S7:1w, label=hasInterest, type=edge, outV=1:2Ea, outVLabel=Person, inV=7:1w, inVLabel=Tag, properties={}}
{id=S1:2Ea>10>>S7:24Z, label=hasInterest, type=edge, outV=1:2Ea, outVLabel=Person, inV=7:24Z, inVLabel=Tag, properties={}}
{id=S1:2Ea>10>>S7:28q, label=hasInterest, type=edge, outV=1:2Ea, outVLabel=Person, inV=7:28q, inVLabel=Tag, properties={}}
### Vertex/Edge example (问题点 / 边数据举例)
```javascript
{
"vertices": [
{
"label": "Person",
"input": {
"type": "file",
"path": "data/person_without_birthday.csv",
"format": "TEXT",
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"header" : ["id", "firstName", "lastName", "gender", "creationDate", "locationIP", "browserUsed"],
"delimiter": "|"
},
"field_mapping": {"id": "id"}
},
{
"label": "Post",
"update_strategies": {
"language": "APPEND"
},
"input": {
"type": "file",
"path": "data/post_0_0.csv",
"format": "TEXT",
"header": ["id", "imageFile", "creationDate", "locationIP", "browserUsed", "language", "content", "length"],
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"delimiter": "|",
"list_format": {
"start_symbol": "",
"elem_delimiter": ",",
"end_symbol": ""
}
},
"field_mapping": {"id": "id"}
},
{
"label": "Comment",
"input": {
"type": "file",
"path": "data/comment_0_0.csv",
"format": "TEXT",
"header": ["id", "creationDate", "locationIP", "browserUsed", "content", "length"],
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"delimiter": "|"
},
"field_mapping": {"id": "id"}
},
{
"label": "Forum",
"input": {
"type": "file",
"path": "data/forum_0_0.csv",
"format": "TEXT",
"header": ["id", "title", "creationDate"],
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"delimiter": "|"
},
"field_mapping": {"id": "id"}
},
{
"label": "Organisation",
"input": {
"type": "file",
"path": "data/organisation_0_0.csv",
"header": ["id", "type", "name", "url"],
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {"id": "id"}
},
{
"label": "Place",
"input": {
"type": "file",
"path": "data/place_0_0.csv",
"header": ["id", "name", "url", "type"],
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {"id": "id"}
},
{
"label": "Tag",
"input": {
"type": "file",
"path": "data/tag_0_0.csv",
"header": ["id", "name", "url"],
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {"id": "id"}
},
{
"label": "TagClass",
"input": {
"type": "file",
"path": "data/tagclass_0_0.csv",
"header": ["id", "name", "url"],
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {"id": "id"}
}
],
"edges": [
{
"label": "hasCreator2",
"source": ["Comment.id"],
"target": ["Person.id"],
"input": {
"type": "file",
"path": "data/comment_hasCreator_person_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Comment.id": "id",
"Person.id": "id"
}
},
{
"label": "hasTag3",
"source": ["Comment.id"],
"target": ["Tag.id"],
"input": {
"type": "file",
"path": "data/comment_hasTag_tag_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Comment.id": "id",
"Tag.id": "id"
}
},
{
"label": "isLocatedIn1",
"source": ["Comment.id"],
"target": ["Place.id"],
"input": {
"type": "file",
"path": "data/comment_isLocatedIn_place_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Comment.id": "id",
"Place.id": "id"
}
},
{
"label": "replyOf2",
"source": ["Comment1.id"],
"target": ["Comment2.id"],
"input": {
"type": "file",
"path": "data/comment_replyOf_comment_0_0.csv",
"format": "TEXT",
"header":["Comment1.id", "Comment2.id" ],
"skipped_line": {
"regex": "\\w*\\.\\w*\\|\\w*\\.\\w*"
},
"delimiter": "|"
},
"field_mapping": {
"Comment1.id": "id",
"Comment2.id": "id"
}
},
{
"label": "replyOf1",
"source": ["Comment.id"],
"target": ["Post.id"],
"input": {
"type": "file",
"path": "data/comment_replyOf_post_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Comment.id": "id",
"Post.id": "id"
}
},
{
"label": "containerOf",
"source": ["Forum.id"],
"target": ["Post.id"],
"input": {
"type": "file",
"path": "data/forum_containerOf_post_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Forum.id": "id",
"Post.id": "id"
}
},
{
"label": "hasMember",
"source": ["Forum.id"],
"target": ["Person.id"],
"input": {
"type": "file",
"path": "data/forum_hasMember_person_0_0.csv",
"format": "TEXT",
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"delimiter": "|"
},
"field_mapping": {
"Forum.id": "id",
"Person.id": "id"
}
},
{
"label": "hasModerator",
"source": ["Forum.id"],
"target": ["Person.id"],
"input": {
"type": "file",
"path": "data/forum_hasModerator_person_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Forum.id": "id",
"Person.id": "id"
}
},
{
"label": "hasTag1",
"source": ["Forum.id"],
"target": ["Tag.id"],
"input": {
"type": "file",
"path": "data/forum_hasTag_tag_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Forum.id": "id",
"Tag.id": "id"
}
},
{
"label": "isLocatedIn4",
"source": ["Organisation.id"],
"target": ["Place.id"],
"input": {
"type": "file",
"path": "data/organisation_isLocatedIn_place_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Organisation.id": "id",
"Place.id": "id"
}
},
{
"label": "hasInterest",
"source": ["Person.id"],
"target": ["Tag.id"],
"input": {
"type": "file",
"path": "data/person_hasInterest_tag_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Tag.id": "id"
}
},
{
"label": "isLocatedIn3",
"source": ["Person.id"],
"target": ["Place.id"],
"input": {
"type": "file",
"path": "data/person_isLocatedIn_place_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Place.id": "id"
}
},
{
"label": "knows",
"source": ["Person1.id"],
"target": ["Person2.id"],
"input": {
"type": "file",
"path": "data/person_knows_person_0_0.csv",
"format": "TEXT",
"header":["Person1.id", "Person2.id", "creationDate"],
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"skipped_line": {
"regex": "\\w*\\.\\w*\\|\\w*\\.\\w*\\|\\w*"
},
"delimiter": "|"
},
"field_mapping": {
"Person1.id": "id",
"Person2.id": "id"
}
},
{
"label": "likes1",
"source": ["Person.id"],
"target": ["Comment.id"],
"input": {
"type": "file",
"path": "data/person_likes_comment_0_0.csv",
"format": "TEXT",
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Comment.id": "id"
}
},
{
"label": "likes2",
"source": ["Person.id"],
"target": ["Post.id"],
"input": {
"type": "file",
"path": "data/person_likes_post_0_0.csv",
"format": "TEXT",
"date_format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Post.id": "id"
}
},
{
"label": "studyAt",
"source": ["Person.id"],
"target": ["Organisation.id"],
"input": {
"type": "file",
"path": "data/person_studyAt_organisation_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Organisation.id": "id"
}
},
{
"label": "workAt",
"source": ["Person.id"],
"target": ["Organisation.id"],
"input": {
"type": "file",
"path": "data/person_workAt_organisation_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Organisation.id": "id"
}
},
{
"label": "isPartOf",
"source": ["Place1.id"],
"target": ["Place2.id"],
"input": {
"type": "file",
"path": "data/place_isPartOf_place_0_0.csv",
"skipped_line": {
"regex": "\\w*\\.\\w*\\|\\w*\\.\\w*"
},
"header":["Place1.id", "Place2.id"],
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Place1.id": "id",
"Place2.id": "id"
}
},
{
"label": "hasCreator1",
"source": ["Post.id"],
"target": ["Person.id"],
"input": {
"type": "file",
"path": "data/post_hasCreator_person_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Person.id": "id",
"Post.id": "id"
}
},
{
"label": "hasTag2",
"source": ["Post.id"],
"target": ["Tag.id"],
"input": {
"type": "file",
"path": "data/post_hasTag_tag_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Post.id": "id",
"Tag.id": "id"
}
},
{
"label": "isLocatedIn2",
"source": ["Post.id"],
"target": ["Place.id"],
"input": {
"type": "file",
"path": "data/post_isLocatedIn_place_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Post.id": "id",
"Place.id": "id"
}
},
{
"label": "hasType",
"source": ["Tag.id"],
"target": ["TagClass.id"],
"input": {
"type": "file",
"path": "data/tag_hasType_tagclass_0_0.csv",
"format": "TEXT",
"delimiter": "|"
},
"field_mapping": {
"Tag.id": "id",
"TagClass.id": "id"
}
},
{
"label": "isSubclassOf",
"source": ["TagClass1.id"],
"target": ["TagClass2.id"],
"input": {
"type": "file",
"path": "data/tagclass_isSubclassOf_tagclass_0_0.csv",
"format": "TEXT",
"header": ["TagClass1.id", "TagClass2.id"],
"skipped_line": {
"regex": "\\w*\\.\\w*\\|\\w*\\.\\w*"
},
"delimiter": "|"
},
"field_mapping": {
"TagClass1.id": "id",
"TagClass2.id": "id"
}
}
]
}
```
### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
```javascript
// Define schema
schema.propertyKey("id").asLong().ifNotExist().create();
schema.propertyKey("creationDate").asDate().ifNotExist().create();
schema.propertyKey("firstName").asText().ifNotExist().create();
schema.propertyKey("lastName").asText().ifNotExist().create();
schema.propertyKey("gender").asText().ifNotExist().create();
schema.propertyKey("email").asText().valueList().ifNotExist().create();
schema.propertyKey("birthday").asDate().ifNotExist().create();
schema.propertyKey("language").asText().valueList().ifNotExist().create();
schema.propertyKey("browserUsed").asText().ifNotExist().create();
schema.propertyKey("locationIP").asText().ifNotExist().create();
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("type").asText().ifNotExist().create();
schema.propertyKey("url").asText().ifNotExist().create();
schema.propertyKey("title").asText().ifNotExist().create();
schema.propertyKey("content").asText().ifNotExist().create();
schema.propertyKey("length").asInt().ifNotExist().create();
schema.propertyKey("imageFile").asText().ifNotExist().create();
schema.propertyKey("classYear").asInt().ifNotExist().create();
schema.propertyKey("workFrom").asInt().ifNotExist().create();
schema.propertyKey("joinDate").asDate().ifNotExist().create();
//vertexLabel
schema.vertexLabel("Person")
.properties("id", "creationDate", "firstName", "lastName", "gender", "birthday", "email", "language", "browserUsed", "locationIP")
.primaryKeys("id")
.nullableKeys("creationDate", "firstName", "lastName", "gender", "birthday", "email", "language", "browserUsed", "locationIP")
.ifNotExist().create();
schema.vertexLabel("Organisation")
.properties("id","type", "name", "url")
.primaryKeys("id")
.nullableKeys("type", "name", "url")
.ifNotExist().create();
schema.vertexLabel("Place")
.properties("id", "name", "url", "type")
.primaryKeys("id")
.nullableKeys("name", "url", "type")
.ifNotExist().create();
schema.vertexLabel("Post")
.properties("id", "creationDate", "browserUsed", "locationIP", "content", "length", "language", "imageFile")
.primaryKeys("id")
.nullableKeys( "creationDate", "browserUsed", "locationIP", "content", "length", "language", "imageFile")
.ifNotExist().create();
schema.vertexLabel("Comment")
.properties("id","creationDate", "browserUsed", "locationIP", "content", "length")
.primaryKeys("id")
.nullableKeys( "creationDate", "browserUsed", "locationIP", "content", "length")
.ifNotExist().create();
schema.vertexLabel("Forum")
.properties("id", "title", "creationDate")
.primaryKeys("id")
.nullableKeys("title", "creationDate")
.ifNotExist().create();
schema.vertexLabel("Tag")
.properties("id", "name", "url")
.primaryKeys("id")
.nullableKeys( "name", "url")
.ifNotExist().create();
schema.vertexLabel("TagClass")
.properties("id", "name", "url")
.primaryKeys("id")
.nullableKeys( "name", "url")
.ifNotExist().create();
//edgeLabel
schema.edgeLabel("knows").link("Person", "Person").properties("creationDate").nullableKeys("creationDate").ifNotExist().create();
schema.edgeLabel("studyAt").link("Person", "Organisation").properties("classYear").nullableKeys("classYear").ifNotExist().create();
schema.edgeLabel("workAt").link("Person", "Organisation").properties("workFrom").nullableKeys("workFrom").ifNotExist().create();
schema.edgeLabel("likes1").link("Person", "Comment").properties("creationDate").nullableKeys("creationDate").ifNotExist().create();
schema.edgeLabel("likes2").link("Person", "Post").properties("creationDate").nullableKeys("creationDate").ifNotExist().create();
schema.edgeLabel("hasMember").link("Forum", "Person").properties("joinDate").nullableKeys("joinDate").ifNotExist().create();
schema.edgeLabel("containerOf").link("Forum", "Post").ifNotExist().create();
schema.edgeLabel("hasCreator1").link("Post", "Person").ifNotExist().create();
schema.edgeLabel("hasCreator2").link("Comment", "Person").ifNotExist().create();
schema.edgeLabel("hasInterest").link("Person", "Tag").ifNotExist().create();
schema.edgeLabel("hasModerator").link("Forum", "Person").ifNotExist().create();
schema.edgeLabel("hasTag1").link("Forum", "Tag").ifNotExist().create();
schema.edgeLabel("hasTag2").link("Post", "Tag").ifNotExist().create();
schema.edgeLabel("hasTag3").link("Comment", "Tag").ifNotExist().create();
schema.edgeLabel("isLocatedIn1").link("Comment", "Place").ifNotExist().create();
schema.edgeLabel("isLocatedIn2").link("Post", "Place").ifNotExist().create();
schema.edgeLabel("isLocatedIn3").link("Person", "Place").ifNotExist().create();
schema.edgeLabel("isLocatedIn4").link("Organisation", "Place").ifNotExist().create();
schema.edgeLabel("isPartOf").link("Place", "Place").ifNotExist().create();
schema.edgeLabel("isSubclassOf").link("TagClass", "TagClass").ifNotExist().create();
schema.edgeLabel("replyOf1").link("Comment", "Post").ifNotExist().create();
schema.edgeLabel("replyOf2").link("Comment", "Comment").ifNotExist().create();
schema.edgeLabel("hasType").link("Tag", "TagClass").ifNotExist().create();
//indexForVertex
// schema.indexLabel("personById").onV("Person").by("id").secondary().ifNotExist().create();
// schema.indexLabel("organisationById").onV("Organisation").by("id").secondary().ifNotExist().create();
// schema.indexLabel("placeById").onV("Place").by("id").secondary().ifNotExist().create();
// schema.indexLabel("postById").onV("Post").by("id").secondary().ifNotExist().create();
// schema.indexLabel("commentById").onV("Comment").by("id").secondary().ifNotExist().create();
// schema.indexLabel("forumById").onV("Forum").by("id").secondary().ifNotExist().create();
// schema.indexLabel("tagById").onV("Tag").by("id").secondary().ifNotExist().create();
// schema.indexLabel("tagClassById").onV("TagClass").by("id").secondary().ifNotExist().create();
schema.indexLabel("personByFirstName").onV("Person").by("firstName").secondary().ifNotExist().create();
schema.indexLabel("personByLastName").onV("Person").by("lastName").secondary().ifNotExist().create();
schema.indexLabel("personByDate").onV("Person").by("creationDate").range().ifNotExist().create();
//schema.indexLabel("personByBirthday").onV("Person").by("birthday").range().ifNotExist().create();
schema.indexLabel("postByDate").onV("Post").by("creationDate").range().ifNotExist().create();
schema.indexLabel("commentByDate").onV("Comment").by("creationDate").range().ifNotExist().create();
//IndexForEdge
schema.indexLabel("knowsByDate").onE("knows").by("creationDate").range().ifNotExist().create();
schema.indexLabel("studyAtByDate").onE("studyAt").by("classYear").range().ifNotExist().create();
schema.indexLabel("likesByDate1").onE("likes1").by("creationDate").range().ifNotExist().create();
schema.indexLabel("likesByDate2").onE("likes2").by("creationDate").range().ifNotExist().create();
schema.indexLabel("joinByDate").onE("hasMember").by("joinDate").range().ifNotExist().create();
schema.indexLabel("workAtByDate").onE("workAt").by("workFrom").range().ifNotExist().create();
```
Contributor guide
Assessment
This issue has not been assessed yet.