sanne.grinovero wrote:
In the specific case, the StandardTokenizerFactory - which you're using - is splitting the terms on whitespace, so any keyword will be stored separately! you would need to query for "learning" and "hibernate" as two different terms if you want to use the TermQuery.
Thank you for your answer, but I'm not sure if my post was not clear enough or I didn't understand your idea. The query I'm using for searching titles doesn't use TermQuery. TermQuery is used in BooleanQuery that should exclude specific LearningGoal based on id.
Code:
for (LearningGoal exGoal : existingGoals) {
Term omittedTerm = new Term("id", String.valueOf(exGoal.getId()));
bQuery.add(new TermQuery(omittedTerm), BooleanClause.Occur.MUST_NOT);
}
The first query that searches LearningGoal by title, doesn't have any TermQuery. I tried even without this BooleanQuery that uses the TermQuery and the result is the same. So the following code still doesn't work:
Code:
QueryBuilder qBuilder = fullTextSession.getSearchFactory()
.buildQueryBuilder().forEntity(LearningGoal.class).get();
Query query = qBuilder.keyword().wildcard().onField("title")
.matching(searchString + "*").createQuery();
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(
bQuery, LearningGoal.class);
Isn't this the same approach as suggested in http://docs.jboss.org/hibernate/search/4.2/reference/en-US/html_single/#search-query-querydsl ?