| Robin Schimpf I'm afraid it's more a problem with the query than with Hibernate Search. The thing is, the matching method doesn't expect a query to be parsed; it expects a string to be analyzed. You don't get to use operators like OR in this string. If you want to check it out ourself, the code performing this analysis (not query parsing, just text analysis) is in org.hibernate.search.query.dsl.impl.Helper.getAllTermsFromText(String, String, Analyzer). In you example, the concatenated string has been analysed and the operators have been removed by the analyzer (probably because they are stop words). The ID query came out different because IDs are, by default, not analyzed. In order to do what you want, you should build one "keyword" query per title, and aggregate those queries in a boolean query with "should" clauses. Something like that:
List<String> titles = new ArrayList<>();
titles.add("Test1");
titles.add("Test2");
titles.add("Test2");
BooleanJunction<?> junction = builder.bool();
titles.stream().forEach( title -> junction.should( builder.keyword().withConstantScore().onField("title").matching(title).createQuery() ) );
Query titleQuery = junction.createQuery();
logger.info("Title Query: {}", titleQuery);
FullTextQuery ftq = fullTextSession.createFullTextQuery(titleQuery);
Could you please confirm this solves your issue, so I can close this ticket? Thanks |