use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testAddIndexLabelWithUserData.
@Test
public void testAddIndexLabelWithUserData() {
SchemaManager schema = schema();
BaseFuncTest.initVertexLabel();
IndexLabel personByCity = schema.indexLabel("personByCity").onV("person").by("city").secondary().userdata("type", "secondary").ifNotExist().create();
Assert.assertEquals(2, personByCity.userdata().size());
Assert.assertEquals("secondary", personByCity.userdata().get("type"));
String time = (String) personByCity.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
IndexLabel personByAge = schema.indexLabel("personByAge").onV("person").by("age").range().userdata("type", "secondary").userdata("type", "range").ifNotExist().create();
Assert.assertEquals(2, personByAge.userdata().size());
Assert.assertEquals("range", personByAge.userdata().get("type"));
time = (String) personByAge.userdata().get("~create_time");
createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testRemoveIndexLabelAsync.
@Test
public void testRemoveIndexLabelAsync() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().create();
Assert.assertNotNull(playerByName);
// Remove index label async
schema.removeIndexLabelAsync("playerByName");
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testIndexLabel.
@Test
public void testIndexLabel() {
IndexLabel.Builder builder = new IndexLabel.BuilderImpl("personByAge", null);
IndexLabel indexLabel = builder.onV("person").secondary().by("age").build();
String json = "{\"name\":\"personByAge\",\"id\":0," + "\"check_exist\":true,\"user_data\":{}," + "\"base_type\":\"VERTEX_LABEL\"," + "\"base_value\":\"person\"," + "\"index_type\":\"SECONDARY\",\"fields\":[\"age\"]," + "\"rebuild\":true}";
Assert.assertEquals(json, JsonUtil.toJson(indexLabel));
Assert.assertEquals(HugeType.INDEX_LABEL.string(), indexLabel.type());
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelApiTest method testCreateWithIndexType.
@Test
public void testCreateWithIndexType() {
IndexLabel indexLabel = schema().indexLabel("personByAge").onV("person").by("age").indexType(IndexType.RANGE).build();
Assert.assertEquals("personByAge", indexLabel.name());
Assert.assertEquals(HugeType.VERTEX_LABEL, indexLabel.baseType());
Assert.assertEquals("person", indexLabel.baseValue());
Assert.assertEquals(IndexType.RANGE, indexLabel.indexType());
List<String> fields = ImmutableList.of("age");
Assert.assertTrue(fields.size() == indexLabel.indexFields().size());
Assert.assertTrue(fields.containsAll(indexLabel.indexFields()));
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelApiTest method testCreateRangeIndexOnNotNumberProperty.
@Test
public void testCreateRangeIndexOnNotNumberProperty() {
IndexLabel indexLabel = schema().indexLabel("personByCity").onV("person").by("city").range().build();
Utils.assertResponseError(400, () -> {
indexLabelAPI.create(indexLabel);
});
}
Aggregations