QueryFactory qf = Search.getSearchManager(cache2).getQueryFactory();
// all male users, but this time retrieved in a twisted manner
Query q = qf.from(User.class)
.not(qf.having("gender").eq(User.Gender.FEMALE))
.and(qf.not().not(qf.having("gender").eq(User.Gender.MALE)))
.toBuilder().build();
List<User> list = q.list();
assertEquals(2, list.size());
assertEquals("John", list.get(0).getName());