Assert.assertTrue( documentsIndexManager.getClass().equals( org.hibernate.search.indexes.impl.NRTIndexManager.class ) );
NRTIndexManager indexManager = (NRTIndexManager) documentsIndexManager;
Session s = getSessionFactory().openSession();
s.getTransaction().begin();
Document document =
new Document( "Hibernate in Action", "Object/relational mapping with Hibernate", "blah blah blah" );
s.persist( document );
s.flush();
s.persist(
new AlternateDocument(
document.getId(),
"Hibernate in Action",
"Object/relational mapping with Hibernate",
"blah blah blah"
)
);
s.getTransaction().commit();
s.close();
assertEquals( 0, getDocumentNbrFromFilesystem( indexManager ) );
assertEquals( 2, getDocumentNbrFromReaderProvider( indexManager ) );
s = getSessionFactory().openSession();
s.getTransaction().begin();
TermQuery q = new TermQuery( new Term( "alt_title", "hibernate" ) );
assertEquals(
"does not properly filter", 0,
Search.getFullTextSession( s ).createFullTextQuery( q, Document.class ).list().size()
);
assertEquals(
"does not properly filter", 1,
Search.getFullTextSession( s )
.createFullTextQuery( q, Document.class, AlternateDocument.class )
.list().size()
);
s.delete( s.get( AlternateDocument.class, document.getId() ) );
s.getTransaction().commit();
s.close();
s = getSessionFactory().openSession();
s.getTransaction().begin();