We have been using Hibernate Search 5.11.7.Final but because of some features with syntax highlighting we decided to upgrade to Hibernate Search 6.
Until now we have been using a MultiFieldQueryParser for the search term adding some date and numerice range queries like e.g.
final Query fromRangeQuery = builder.range().onField(nqd.getIndexFromDate())
.above(nqd.getFromDate().atStartOfDay()).createQuery();
booleanQuery.add(fromRangeQuery, BooleanClause.Occur.MUST);
and passing the booleanQuery to Hibernate Search FullTextQuery, working like a charm.
Now we try using something like this:
final SearchQuery<MyEntity> query = session.search(MyEntity.class)
.where(f -> f.bool(b -> {
b.must(f.match()
.fields(IndexField1,
IndexField1,
IndexField3)
.matching("SearchTerm"));
b.must(f.range().fields(queryDto.getIndex).atLeast(queryDto.getFrom()));
})).sort(SortOrder.DESC).toQuery();
which is a Hibernate Search Query but the MultiFieldQueryParser seems to be available only in Lucene
and this works:
QueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
List<MyClass> hits = searchSession.search( MyClass.class )
.extension( LuceneExtension.get() )
.predicate( f -> f.fromLuceneQuery( parser.parse(terms) ) )
.fetchHits();
Hibernate-search 6 MultiFieldQueryParser equivalent
The only problem left is:
How can I combine those two queries?
Best regards