Suggestion : enrich HSearch API with a "matching in" predicate

Hi everyone,

I just need to query if a given value is contained in a list of value. In SQL we simply use the IN operator :

…where entity.id in (1,2,3)

Can we have the same operator for Hibernate search, this allows to less code for us :slight_smile: :

For instance :

List<ChoixMentionMicen> unmatchingList = Arrays.asList(ChoixMentionMicen.MENTION_EXECUTOIRE_A_ORDRE, ChoixMentionMicen.MENTION_EXECUTOIRE_NOMINATIVE, ChoixMentionMicen.NOTE_SIMPLE_INFORMATION, ChoixMentionMicen.MENTION_RECTIFICATIVE);
 PredicateFinalStep b = fa.bool(b0 -> b0.mustNot(fa.match().field(MentionMicen_.NATURE).matching(unmatchingList, ValueConvert.NO)));

Of course, the HSearch gurus gave the solution here :

But I hope that the IN operator should be provided…of course, we could extend this kind of need to be closer to JPA API (coalesce(), between, disjunction, etc.)

Less user code = less bug.

Thanks.

I think you want the terms predicate, which was added in Hibernate Search 6.1.0.Alpha1. So you just have to upgrade :slight_smile:

Yes you’re right, I saw the ticket : [HSEARCH-2589] Add syntactic sugar to the QueryDSL for simple multiple-term keyword matches - Hibernate JIRA
But here at work, we prefer final version :).
We are still at 6.0.0 Final … but soon I will remove a part of my QueryDSLHelper so. Good news !