Search in sources :

Example 16 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class LuceneRangeTest method setUp.

@Before
public void setUp() throws Exception {
    OSchemaProxy schema = db.getMetadata().getSchema();
    OClass cls = schema.createClass("Person");
    cls.createProperty("name", OType.STRING);
    cls.createProperty("surname", OType.STRING);
    cls.createProperty("date", OType.DATETIME);
    cls.createProperty("age", OType.INTEGER);
    List<String> names = Arrays.asList("John", "Robert", "Jane", "andrew", "Scott", "luke", "Enriquez", "Luis", "Gabriel", "Sara");
    for (int i = 0; i < 10; i++) {
        db.save(new ODocument("Person").field("name", names.get(i)).field("surname", "Reese").field("date", System.currentTimeMillis() - (i * 3600 * 24 * 1000)).field("age", i));
    }
}
Also used : OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Before(org.junit.Before)

Example 17 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class LuceneReuseTest method shouldUseTheRightLuceneIndex.

@Test
public void shouldUseTheRightLuceneIndex() {
    OSchemaProxy schema = db.getMetadata().getSchema();
    OClass cls = schema.createClass("Reuse");
    cls.createProperty("name", OType.STRING);
    cls.createProperty("date", OType.DATETIME);
    cls.createProperty("surname", OType.STRING);
    cls.createProperty("age", OType.LONG);
    db.command(new OCommandSQL("create index Reuse.composite on Reuse (name,surname,date,age) UNIQUE")).execute();
    //lucene on name and surname
    db.command(new OCommandSQL("create index Reuse.name_surname on Reuse (name,surname) FULLTEXT ENGINE LUCENE")).execute();
    for (int i = 0; i < 10; i++) {
        db.save(new ODocument("Reuse").field("name", "John").field("date", new Date()).field("surname", "Reese").field("age", i));
    }
    //additional record
    db.save(new ODocument("Reuse").field("name", "John").field("date", new Date()).field("surname", "Franklin").field("age", 11));
    Collection<ODocument> results = db.command(new OCommandSQL("SELECT FROM Reuse WHERE name='John' and [name,surname] LUCENE 'Reese'")).execute();
    Assert.assertEquals(10, results.size());
    results = db.command(new OCommandSQL("SELECT FROM Reuse WHERE [name,surname] LUCENE 'Reese' and name='John'")).execute();
    Assert.assertEquals(10, results.size());
    results = db.command(new OCommandSQL("SELECT FROM Reuse WHERE name='John' and [name,surname] LUCENE '(surname:Franklin)'")).execute();
    Assert.assertEquals(1, results.size());
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Date(java.util.Date) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

OSchemaProxy (com.orientechnologies.orient.core.metadata.schema.OSchemaProxy)17 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)14 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)10 Test (org.testng.annotations.Test)10 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)7 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)6 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)3 Test (org.junit.Test)3 Date (java.util.Date)2 OException (com.orientechnologies.common.exception.OException)1 OCommandCacheSoftRefs (com.orientechnologies.orient.core.cache.OCommandCacheSoftRefs)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OSecurityException (com.orientechnologies.orient.core.exception.OSecurityException)1 OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)1 OIndexManagerProxy (com.orientechnologies.orient.core.index.OIndexManagerProxy)1 OIndexManagerRemote (com.orientechnologies.orient.core.index.OIndexManagerRemote)1 OIndexManagerShared (com.orientechnologies.orient.core.index.OIndexManagerShared)1 OFunctionLibrary (com.orientechnologies.orient.core.metadata.function.OFunctionLibrary)1 OFunctionLibraryImpl (com.orientechnologies.orient.core.metadata.function.OFunctionLibraryImpl)1 OFunctionLibraryProxy (com.orientechnologies.orient.core.metadata.function.OFunctionLibraryProxy)1