startAndWaitMassIndexing( Insurance.class );
}
{
FullTextSession session = Search.getFullTextSession( openSession() );
QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEntity( Insurance.class ).get();
Query luceneQuery = queryBuilder.keyword().wildcard().onField( "name" ).matching( "ins*" ).createQuery();
Transaction transaction = session.beginTransaction();
@SuppressWarnings("unchecked")
List<Insurance> list = session.createFullTextQuery( luceneQuery ).list();
assertThat( list ).hasSize( 1 );
assertThat( list.get( 0 ).getName() ).isEqualTo( "Insurance Corporation" );