{
LuceneIndexer indexer = LuceneIndexer.getInstance(LUCENE_DIR_PATH);
IndexManager ixManager = new IndexManager(indexer, ((EntityManagerFactoryImpl)emf).getKunderaMetadataInstance());
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(((EntityManagerFactoryImpl)emf).getKunderaMetadataInstance(), Person.class);
Person p = new Person();
p.setAge(32);
p.setDay(Day.TUESDAY);
p.setPersonId("p1");
Assert.assertNotNull(ixManager.getIndexer());
Assert.assertEquals(indexer, ixManager.getIndexer());
ixManager.write(metadata, p);
String luceneQuery = "+Person.AGE:32 AND +entity.class:com.impetus.kundera.query.Person";
try
{
Map<String, Object> results = ixManager.search(metadata.getEntityClazz(), luceneQuery, 0, 10, false);
Assert.assertTrue(!results.isEmpty());
}
catch (LuceneIndexingException liex)
{
Assert.fail();
}
p.setAge(35);
ixManager.update(metadata, p, null, Person.class);
luceneQuery = "+Person.AGE:35 AND +entity.class:com.impetus.kundera.query.Person";
try