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();
}
}
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();
}
}
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();
}
}
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();
}
}
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);
}
Aggregations