{ // Store guest "Thorin Oakenshield" in the index
Guest lastDwarf = new Guest();
lastDwarf.id = 13l;
lastDwarf.name = "Thorin Oakenshield";
Work work = new Work( lastDwarf, lastDwarf.id, WorkType.ADD, false );
TransactionContextForTest tc = new TransactionContextForTest();
searchFactory.getWorker().performWork( work, tc );
tc.end();
}
QueryBuilder guestQueryBuilder = searchFactory.buildQueryBuilder()
.forEntity( Guest.class )
.get();
Query queryAllGuests = guestQueryBuilder.all().createQuery();
List<EntityInfo> queryEntityInfos = searchFactory.createHSQuery()
.luceneQuery( queryAllGuests )
.targetedEntities( Arrays.asList( new Class<?>[]{ Guest.class } ) )
.queryEntityInfos();
Assert.assertEquals( 1, queryEntityInfos.size() );
Assert.assertEquals( 13L, queryEntityInfos.get( 0 ).getId() );
RecordingFilter filter = new RecordingFilter( "name" );
List<EntityInfo> filteredQueryEntityInfos = searchFactory.createHSQuery()
.luceneQuery( queryAllGuests )
.targetedEntities( Arrays.asList( new Class<?>[]{ Guest.class } ) )
.filter( filter )
.queryEntityInfos();
checkFilterInspectedAllSegments( filter );
expectedTermsForFilter( filter, "thorin", "oakenshield" );
Assert.assertEquals( 1, filteredQueryEntityInfos.size() );
Assert.assertEquals( 13L, filteredQueryEntityInfos.get( 0 ).getId() );
{ // Store guest "Balin"
Guest balin = new Guest();
balin.id = 7l;
balin.name = "Balin";
Work work = new Work( balin, balin.id, WorkType.ADD, false );
TransactionContextForTest tc = new TransactionContextForTest();
searchFactory.getWorker().performWork( work, tc );
tc.end();
}