Reputation: 1745
I have an Indexed enum with multiple values Active, Pending, Pulled. I was to devise a query that will get only Active and Pulled, but not Pending.
junction = junction.must(
qb.keyword().onField("itemStatus").ignoreFieldBridge()
.matching("active pulled").createQuery());
the query above is my first stab at it, but this doesn't return anything unless I change the query to only active or change the junction to a should. I basically want a must with an and condition...
Upvotes: 0
Views: 504
Reputation: 19119
You will need to separate the two queries for the different matching status:
Query itemStatusQuery = queryBuilder
.bool()
.should(queryBuilder.keyword().onField("itemStatus").matching("active").createQuery())
.should(queryBuilder.keyword().onField("itemStatus").matching("pulled").createQuery())
.createQuery();
junction = junction.must(itemStatusQuery);
Alternatively you might be able to use a must().not()
. See also http://docs.jboss.org/hibernate/search/5.1/reference/en-US/html_single/#_combining_queries
Upvotes: 1