@Test
@TestForIssue(jiraKey = "HSEARCH-3197")
@SuppressWarnings("unchecked")
public void noneOfShouldMatchedWithinBooleanQueryInsideFilterResultReturned() {
try ( Session s = getSessionFactory().openSession() ) {
YourAnnotatedEntity yourEntity = new YourAnnotatedEntity( 1L, "goran", "jaric" );
Transaction tx = s.beginTransaction();
s.persist( yourEntity );
tx.commit();
FullTextSession session = Search.getFullTextSession( s );
QueryBuilder qb = session.getSearchFactory().buildQueryBuilder().forEntity( YourAnnotatedEntity.class ).get();
Query query = qb.bool().must(new BooleanQuery.Builder()
.add(new TermQuery(new Term("id", "1")), BooleanClause.Occur.MUST).build())
.filteredBy(new BooleanQuery.Builder()
.add(new TermQuery(new Term("firstName", "non-existing")), BooleanClause.Occur.SHOULD) .add(new TermQuery(new Term("lastName", "jaric")), BooleanClause.Occur.MUST)
.build()
)
.createQuery();
List<YourAnnotatedEntity> result = (List<YourAnnotatedEntity>) session.createFullTextQuery( query ).list();
assertEquals( 0, result.size() );
}
}