Search in sources :

Example 11 with OSchema

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

the class LuceneExportImportTest method init.

@Before
public void init() {
    OSchema schema = db.getMetadata().getSchema();
    OClass oClass = schema.createClass("City");
    oClass.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
    ODocument doc = new ODocument("City");
    doc.field("name", "Rome");
    db.save(doc);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Before(org.junit.Before)

Example 12 with OSchema

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

the class LuceneFacetTest method init.

@Before
public void init() {
    OSchema schema = db.getMetadata().getSchema();
    OClass oClass = schema.createClass("Item");
    oClass.createProperty("name", OType.STRING);
    oClass.createProperty("category", OType.STRING);
    db.command(new OCommandSQL("create index Item.name_category on Item (name,category) FULLTEXT ENGINE LUCENE METADATA { 'facetFields' : ['category']}")).execute();
    ODocument doc = new ODocument("Item");
    doc.field("name", "Pioneer");
    doc.field("category", "Electronic/HiFi");
    db.save(doc);
    doc = new ODocument("Item");
    doc.field("name", "Hitachi");
    doc.field("category", "Electronic/HiFi");
    db.save(doc);
    doc = new ODocument("Item");
    doc.field("name", "Philips");
    doc.field("category", "Electronic/HiFi");
    db.save(doc);
    doc = new ODocument("Item");
    doc.field("name", "HP");
    doc.field("category", "Electronic/Computer");
    db.save(doc);
    db.commit();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Before(org.junit.Before)

Example 13 with OSchema

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

the class LuceneFreezeReleaseTest method freezeReleaseMisUsageTest.

// With double calling freeze/release
@Test
public void freezeReleaseMisUsageTest() {
    ODatabaseDocument db = new ODatabaseDocumentTx("plocal:target/freezeRelease");
    db.create();
    OSchema schema = db.getMetadata().getSchema();
    OClass person = schema.createClass("Person");
    person.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index Person.name on Person (name) FULLTEXT ENGINE LUCENE")).execute();
    db.save(new ODocument("Person").field("name", "John"));
    try {
        Collection results = db.command(new OCommandSQL("select from Person where name lucene 'John'")).execute();
        Assert.assertEquals(1, results.size());
        db.freeze();
        db.freeze();
        results = db.command(new OCommandSQL("select from Person where name lucene 'John'")).execute();
        Assert.assertEquals(1, results.size());
        db.release();
        db.release();
        db.save(new ODocument("Person").field("name", "John"));
        results = db.command(new OCommandSQL("select from Person where name lucene 'John'")).execute();
        Assert.assertEquals(2, results.size());
    } finally {
        db.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Collection(java.util.Collection) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 14 with OSchema

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

the class LuceneMiscTest method dottedNotationTest.

@Test
public void dottedNotationTest() {
    OrientGraphNoTx db = new OrientGraphNoTx("memory:dotted");
    try {
        OSchema schema = db.getRawGraph().getMetadata().getSchema();
        OClass v = schema.getClass("V");
        OClass e = schema.getClass("E");
        OClass author = schema.createClass("Author");
        author.setSuperClass(v);
        author.createProperty("name", OType.STRING);
        OClass song = schema.createClass("Song");
        song.setSuperClass(v);
        song.createProperty("title", OType.STRING);
        OClass authorOf = schema.createClass("AuthorOf");
        authorOf.createProperty("in", OType.LINK, song);
        authorOf.setSuperClass(e);
        db.command(new OCommandSQL("create index AuthorOf.in on AuthorOf (in) NOTUNIQUE")).execute();
        db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute();
        OrientVertex authorVertex = db.addVertex("class:Author", new String[] { "name", "Bob Dylan" });
        OrientVertex songVertex = db.addVertex("class:Song", new String[] { "title", "hurricane" });
        authorVertex.addEdge("AuthorOf", songVertex);
        List<Object> results = db.getRawGraph().command(new OCommandSQL("select from AuthorOf")).execute();
        Assert.assertEquals(results.size(), 1);
        results = db.getRawGraph().command(new OCommandSQL("select from AuthorOf where in.title lucene 'hurricane'")).execute();
        Assert.assertEquals(results.size(), 1);
    } finally {
        db.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) Test(org.junit.Test)

Example 15 with OSchema

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

the class LuceneInsertIntegrityRemoteTest method init.

@Before
public void init() {
    OSchema schema = db.getMetadata().getSchema();
    OClass oClass = schema.createClass("City");
    oClass.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Before(org.junit.Before)

Aggregations

OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)203 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)165 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)122 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)54 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)46 Test (org.testng.annotations.Test)35 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)31 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)23 Test (org.junit.Test)19 Before (org.junit.Before)16 ORID (com.orientechnologies.orient.core.id.ORID)15 OIndex (com.orientechnologies.orient.core.index.OIndex)15 Collection (java.util.Collection)15 Set (java.util.Set)15 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)9 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)9 BeforeClass (org.testng.annotations.BeforeClass)9 OStorage (com.orientechnologies.orient.core.storage.OStorage)6 ArrayList (java.util.ArrayList)5 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)4