Search in sources :

Example 46 with IndexLabel

use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.

the class IndexLabelApiTest method testCreateSearchIndexOnMultiProperties.

@Test
public void testCreateSearchIndexOnMultiProperties() {
    IndexLabel indexLabel = schema().indexLabel("personByAgeAndCity").onV("person").by("age", "city").search().build();
    Utils.assertResponseError(400, () -> {
        indexLabelAPI.create(indexLabel);
    });
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) Test(org.junit.Test)

Example 47 with IndexLabel

use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.

the class IndexLabelApiTest method testListByNames.

@Test
public void testListByNames() {
    IndexLabel personByAge = fillIndexLabel.apply("personByAge");
    personByAge = indexLabelAPI.create(personByAge).indexLabel();
    IndexLabel personByCity = schema().indexLabel("personByCity").onV("person").by("city").secondary().build();
    personByCity = indexLabelAPI.create(personByCity).indexLabel();
    List<IndexLabel> indexLabels;
    indexLabels = indexLabelAPI.list(ImmutableList.of("personByAge"));
    Assert.assertEquals(1, indexLabels.size());
    assertContains(indexLabels, personByAge);
    indexLabels = indexLabelAPI.list(ImmutableList.of("personByCity"));
    Assert.assertEquals(1, indexLabels.size());
    assertContains(indexLabels, personByCity);
    indexLabels = indexLabelAPI.list(ImmutableList.of("personByAge", "personByCity"));
    Assert.assertEquals(2, indexLabels.size());
    assertContains(indexLabels, personByAge);
    assertContains(indexLabels, personByCity);
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) Test(org.junit.Test)

Example 48 with IndexLabel

use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.

the class IndexLabelApiTest method testCreateOnUndefinedSchemaLabel.

@Test
public void testCreateOnUndefinedSchemaLabel() {
    IndexLabel indexLabel1 = schema().indexLabel("authorByAge").onV("author").by("age").range().build();
    Utils.assertResponseError(400, () -> {
        indexLabelAPI.create(indexLabel1);
    });
    IndexLabel indexLabel2 = schema().indexLabel("writeByDate").onE("write").by("date").secondary().build();
    Utils.assertResponseError(400, () -> {
        indexLabelAPI.create(indexLabel2);
    });
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) Test(org.junit.Test)

Example 49 with IndexLabel

use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.

the class TaskApiTest method testGet.

@Test
public void testGet() {
    IndexLabel personByCity = schema().getIndexLabel("personByCity");
    long taskId = rebuildAPI.rebuild(personByCity);
    Task task = taskAPI.get(taskId);
    Assert.assertNotNull(task);
    Assert.assertEquals(taskId, task.id());
    waitUntilTaskCompleted(taskId);
}
Also used : Task(com.baidu.hugegraph.structure.Task) IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) Test(org.junit.Test)

Example 50 with IndexLabel

use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.

the class TaskApiTest method testDelete.

@Test
public void testDelete() {
    IndexLabel personByCity = schema().getIndexLabel("personByCity");
    long taskId = rebuildAPI.rebuild(personByCity);
    waitUntilTaskCompleted(taskId);
    taskAPI.delete(taskId);
    Utils.assertResponseError(404, () -> {
        taskAPI.get(taskId);
    });
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) Test(org.junit.Test)

Aggregations

IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)56 Test (org.junit.Test)34 HugeClient (com.baidu.hugegraph.driver.HugeClient)14 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)11 ArrayList (java.util.ArrayList)10 ServerException (com.baidu.hugegraph.exception.ServerException)9 ExternalException (com.baidu.hugegraph.exception.ExternalException)8 Task (com.baidu.hugegraph.structure.Task)7 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)7 PropertyIndex (com.baidu.hugegraph.entity.schema.PropertyIndex)6 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)6 Date (java.util.Date)6 RestResult (com.baidu.hugegraph.rest.RestResult)4 HashSet (java.util.HashSet)4 SchemaType (com.baidu.hugegraph.entity.schema.SchemaType)2 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)2 TasksWithPage (com.baidu.hugegraph.api.task.TasksWithPage)1 Constant (com.baidu.hugegraph.common.Constant)1 ConflictDetail (com.baidu.hugegraph.entity.schema.ConflictDetail)1 ConflictStatus (com.baidu.hugegraph.entity.schema.ConflictStatus)1