use of com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition in project orientdb by orientechnologies.
the class ClassIndexTest method testCreateOnePropertyByKeyEmbeddedMapIndex.
@Test
public void testCreateOnePropertyByKeyEmbeddedMapIndex() {
final OIndex result = oClass.createIndex("ClassIndexTestPropertyByKeyEmbeddedMap", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "fEmbeddedMap by key" });
assertEquals(result.getName(), "ClassIndexTestPropertyByKeyEmbeddedMap");
assertEquals(oClass.getClassIndex("ClassIndexTestPropertyByKeyEmbeddedMap").getName(), result.getName());
assertEquals(database.getMetadata().getIndexManager().getClassIndex("ClassIndexTestClass", "ClassIndexTestPropertyByKeyEmbeddedMap").getName(), result.getName());
final OIndexDefinition indexDefinition = result.getDefinition();
assertTrue(indexDefinition instanceof OPropertyMapIndexDefinition);
assertEquals(indexDefinition.getFields().get(0), "fEmbeddedMap");
assertEquals(indexDefinition.getTypes()[0], OType.STRING);
assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.KEY);
}
use of com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testOldStileCreateEmbeddedMapIndex.
@Test
public void testOldStileCreateEmbeddedMapIndex() throws Exception {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexTestClass.prop3 UNIQUE")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexTestClass.prop3");
Assert.assertNotNull(index);
final OIndexDefinition indexDefinition = index.getDefinition();
Assert.assertTrue(indexDefinition instanceof OPropertyMapIndexDefinition);
Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop3"));
Assert.assertEquals(indexDefinition.getTypes(), new OType[] { OType.STRING });
Assert.assertEquals(index.getType(), "UNIQUE");
Assert.assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.KEY);
}
use of com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testCreateEmbeddedMapIndex.
@Test
public void testCreateEmbeddedMapIndex() throws Exception {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexEmbeddedMapIndex ON sqlCreateIndexTestClass (prop3) UNIQUE")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexEmbeddedMapIndex");
Assert.assertNotNull(index);
final OIndexDefinition indexDefinition = index.getDefinition();
Assert.assertTrue(indexDefinition instanceof OPropertyMapIndexDefinition);
Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop3"));
Assert.assertEquals(indexDefinition.getTypes(), new OType[] { OType.STRING });
Assert.assertEquals(index.getType(), "UNIQUE");
Assert.assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.KEY);
}
Aggregations