Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Change-Id: If9f66400b64f4c7835c58e1ce46f12b3a47c5e8d
  • Loading branch information
javeme committed Mar 29, 2022
1 parent 2e0deac commit f229414
Showing 1 changed file with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5191,6 +5191,68 @@ public void testQueryByJointIndexesWithTwoSearchAndOneRangeIndexes() {
Assert.assertEquals(0, vertices.size());
}

@Test
public void testQueryByJointIndexesWithSearchAndTwoRangeIndexesAndWithin() {
SchemaManager schema = graph().schema();

schema.propertyKey("type").asInt().ifNotExist().create();
schema.propertyKey("kid").asInt().ifNotExist().create();
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("confirmType").asInt().ifNotExist().create();

schema.vertexLabel("test")
.properties("confirmType", "name", "kid", "type")
.nullableKeys("confirmType", "name", "type")
.primaryKeys("kid")
.ifNotExist().create();

schema.indexLabel("test_by_type")
.onV("test").by("type")
.range()
.ifNotExist().create();
schema.indexLabel("test_by_confirmType")
.onV("test").by("confirmType")
.range()
.ifNotExist().create();
schema.indexLabel("test_by_name")
.onV("test").by("name")
.search()
.ifNotExist().create();

HugeGraph graph = graph();

graph.addVertex(T.label, "test", "name", "诚信",
"confirmType", 0, "type", 1, "kid", 0);
graph.addVertex(T.label, "test", "name", "诚信",
"confirmType", 1, "type", 1, "kid", 1);
graph.addVertex(T.label, "test", "name", "诚信文明",
"confirmType", 2, "type", 1, "kid", 2);
graph.addVertex(T.label, "test", "name", "诚信文明",
"confirmType", 3, "type", 1, "kid", 3);

List<Vertex> vertices;
vertices = graph().traversal().V()
.has("type", 1)
.has("confirmType", P.within(0, 2, 3))
.has("name", Text.contains("诚信"))
.toList();
Assert.assertEquals(3, vertices.size());

vertices = graph().traversal().V()
.has("type", 1)
.has("confirmType", P.within(0, 2, 3))
.has("name", Text.contains("文明"))
.toList();
Assert.assertEquals(2, vertices.size());

vertices = graph().traversal().V()
.has("type", 0)
.has("confirmType", P.within(0, 1, 3))
.has("name", Text.contains("诚信"))
.toList();
Assert.assertEquals(1, vertices.size());
}

@Test
public void testQueryByShardIndex() {
SchemaManager schema = graph().schema();
Expand Down

0 comments on commit f229414

Please sign in to comment.