Hi everybody, I'm new to Hibernate Search and have the following problem I need to solve:
I currently do the following multifielded query, which works fine:
Code:
MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[]{"name", "album.title", "artists.name", "genres.genre"}, new StandardAnalyzer());
try {
Query query = parser.parse(queryString);
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, Song.class);
return hibQuery.list();
} catch (org.apache.lucene.queryParser.ParseException e) {
log().error("error in searchSongs()");
e.printStackTrace();
}
Generated query is: name:test album.title:test artists.name:test genres.genre:test
With the default setting that means each field is searched with the OR operator. I noticed it's possible to change it with:
Code:
parser.setDefaultOperator(MultiFieldQueryParser.AND_OPERATOR);
However I now want to be able to filter my queries by genres, artists etc. Something like this:
(name:test OR album.title:test OR artists.name:test) AND (genres.genre:pop)
or maybe
(name:test OR album.title:test ) AND (genres.genre:pop) AND (artists.name:Jackson)
Is it possible? Where could I find documentation on how to achieve this?
Cheers!