use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.
the class LuceneManualIndexTest method shouldCreateManualIndexWithJavaApi.
@Test
public void shouldCreateManualIndexWithJavaApi() throws Exception {
ODocument meta = new ODocument().field("analyzer", StandardAnalyzer.class.getName());
OIndex<?> index = db.getMetadata().getIndexManager().createIndex("apiManual", OClass.INDEX_TYPE.FULLTEXT.toString(), new OSimpleKeyIndexDefinition(1, OType.STRING, OType.STRING), null, null, meta, OLuceneIndexFactory.LUCENE_ALGORITHM);
db.command(new OCommandSQL("insert into index:apiManual (key,rid) values(['Enrico','London'],#5:0) ")).execute();
db.command(new OCommandSQL("insert into index:apiManual (key,rid) values(['Luca','Rome'],#5:0) ")).execute();
db.command(new OCommandSQL("insert into index:apiManual (key,rid) values(['Luigi','Rome'],#5:0) ")).execute();
Assert.assertEquals(index.getSize(), 3);
List<ODocument> docs = db.command(new OSQLSynchQuery("select from index:apiManual where key LUCENE '(k0:Enrico)'")).execute();
Assert.assertEquals(docs.size(), 1);
docs = db.command(new OSQLSynchQuery("select from index:apiManual where key LUCENE '(k0:Luca)'")).execute();
Assert.assertEquals(docs.size(), 1);
docs = db.command(new OSQLSynchQuery("select from index:apiManual where key LUCENE '(k1:Rome)'")).execute();
Assert.assertEquals(docs.size(), 2);
docs = db.command(new OSQLSynchQuery("select from index:apiManual where key LUCENE '(k1:London)'")).execute();
Assert.assertEquals(docs.size(), 1);
}
use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.
the class ByteArrayKeyTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
final OClass byteArrayKeyTest = database.getMetadata().getSchema().createClass("ByteArrayKeyTest");
byteArrayKeyTest.createProperty("byteArrayKey", OType.BINARY);
byteArrayKeyTest.createIndex("byteArrayKeyIndex", OClass.INDEX_TYPE.UNIQUE, "byteArrayKey");
final OClass compositeByteArrayKeyTest = database.getMetadata().getSchema().createClass("CompositeByteArrayKeyTest");
compositeByteArrayKeyTest.createProperty("byteArrayKey", OType.BINARY);
compositeByteArrayKeyTest.createProperty("intKey", OType.INTEGER);
compositeByteArrayKeyTest.createIndex("compositeByteArrayKey", OClass.INDEX_TYPE.UNIQUE, "byteArrayKey", "intKey");
database.getMetadata().getIndexManager().createIndex("byte-array-manualIndex-notunique", "NOTUNIQUE", new OSimpleKeyIndexDefinition(-1, OType.BINARY), null, null, null);
}
Aggregations