Search in sources :

Example 31 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class LuceneMiscTest method testNamedParams.

@Test
public void testNamedParams() {
    OrientGraphNoTx graph = new OrientGraphNoTx("memory:doubleLucene");
    try {
        ODatabaseDocumentTx db = graph.getRawGraph();
        db.command(new OCommandSQL("create class Test extends V")).execute();
        db.command(new OCommandSQL("create property Test.attr1 string")).execute();
        db.command(new OCommandSQL("create index Test.attr1 on Test (attr1) fulltext engine lucene")).execute();
        db.command(new OCommandSQL("insert into Test set attr1='foo', attr2='bar'")).execute();
        OSQLSynchQuery query = new OSQLSynchQuery("select from Test where attr1 lucene :name");
        Map params = new HashMap();
        params.put("name", "FOO or");
        List results = db.command(query).execute(params);
        Assert.assertEquals(results.size(), 1);
    } finally {
        graph.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) HashMap(java.util.HashMap) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 32 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx 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 33 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class LuceneMiscTest method testSubLucene.

// TODO Re-enable when removed check syntax on ODB
@Test
public void testSubLucene() {
    OrientGraphNoTx graph = new OrientGraphNoTx("memory:doubleLucene");
    try {
        ODatabaseDocumentTx db = graph.getRawGraph();
        db.command(new OCommandSQL("create class Person extends V")).execute();
        db.command(new OCommandSQL("create property Person.name string")).execute();
        db.command(new OCommandSQL("create index Person.name on Person (name) fulltext engine lucene")).execute();
        db.command(new OCommandSQL("insert into Person set name='Enrico', age=18")).execute();
        OSQLSynchQuery query = new OSQLSynchQuery("select  from (select from Person where age = 18) where name lucene 'Enrico'");
        List results = db.command(query).execute();
        Assert.assertEquals(results.size(), 1);
        // WITH PROJECTION does not work as the class is missing
        query = new OSQLSynchQuery("select  from (select name  from Person where age = 18) where name lucene 'Enrico'");
        results = db.command(query).execute();
        Assert.assertEquals(results.size(), 0);
    } finally {
        graph.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) List(java.util.List) Test(org.junit.Test)

Example 34 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class LuceneNullTest method testNullChangeToNotNullWithLists.

@Test
public void testNullChangeToNotNullWithLists() {
    OrientGraphNoTx graph = new OrientGraphNoTx("memory:testNullChangeToNotNull");
    try {
        ODatabaseDocumentTx db = graph.getRawGraph();
        db.command(new OCommandSQL("create class Test extends V")).execute();
        db.command(new OCommandSQL("create property Test.names EMBEDDEDLIST STRING")).execute();
        db.command(new OCommandSQL("create index Test.names on Test (names) fulltext engine lucene")).execute();
        db.begin();
        ODocument doc = new ODocument("Test");
        db.save(doc);
        db.commit();
        db.begin();
        doc.field("names", new String[] { "foo" });
        db.save(doc);
        db.commit();
        OIndex<?> index = db.getMetadata().getIndexManager().getIndex("Test.names");
        Assert.assertEquals(index.getSize(), 1);
    } finally {
        graph.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 35 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class LuceneInheritanceQueryTest method createSchema.

protected void createSchema(ODatabaseDocumentTx db) {
    final OrientVertexType c1 = new OrientGraphNoTx(db).createVertexType("C1");
    c1.createProperty("name", OType.STRING);
    c1.createIndex("C1.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name" });
    final OrientVertexType c2 = new OrientGraphNoTx(db).createVertexType("C2");
    c2.setSuperClass(c1);
}
Also used : OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)

Aggregations

OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)72 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)28 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)23 Test (org.junit.Test)22 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)20 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)17 OrientVertexType (com.tinkerpop.blueprints.impls.orient.OrientVertexType)17 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)16 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)15 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)7 Vertex (com.tinkerpop.blueprints.Vertex)6 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)6 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)5 OGraphMLReader (com.orientechnologies.orient.graph.graphml.OGraphMLReader)5 OGraphRepair (com.tinkerpop.blueprints.impls.orient.OGraphRepair)5 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 Edge (com.tinkerpop.blueprints.Edge)4 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)3 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)3 File (java.io.File)3