The terms predicate is not yet available in the Hibernate Search DSL.
For non-analyzed text fields or numeric fields, the match predicate will behave similarly to the terms predicate. It does not allow passing multiple values to match (yet), but you can do it yourself with a boolean predicate:
List<String> ids = new ArrayList<>();
ids.add( "kimchy" );
ids.add( "elkbee" );
List<Book> hits = searchSession.search( Book.class )
.where( f -> f.bool( b -> {
for ( String id : ids ) {
b.should( f.match().field( "user.id" ).matching( id ) );
}
} )
.fetchHits( 20 );
To match on the document ID (which I assume has the same value as your id field), I would recommend the id predicate, which (on the contrary to match) offers a matchingAny method accepting multiple values to match:
Finally, if you really need particular JSON and can’t find what you want in the Hibernate Search DSL, you can embed your JSON in the Hibernate Search query.
Be aware that the terms predicate does not perform analysis (tokenization, normalization, etc.), so it’s mostly useful for ID fields, or enum fields, etc. Not for full-text search.