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