Description
Example:
String categories[][] = "foo1", "foo2"}, {"bar1", "bar2";
try {
HstQuery query = getQueryManager().createQuery(getContentBean(request));
final Filter taxonomyFilter = query.createFilter();
for (String keys[] : categories) {
Filter mainCategoryFilter = new FilterImpl();
for (String key : keys) {
final Filter subcategoryFilter = new FilterImpl();
try
catch (FilterException exception)
{ // nothing } }
taxonomyFilter.addAndFilter(mainCategoryFilter);
}
query.setFilter(taxonomyFilter);
query.getQueryAsString(false);
} catch (QueryException exception) {
// nothing
}
Results in query: foo1 + foo2 * (bar1 + bar2)
//*[(@hippo:paths='868e22f8-ad19-4b16-ace5-a7cbeea2cc4b' and @hippostd:state='published' and not(@jcr:primaryType='nt:frozenNode')) and
(@hippotaxonomy:keys = 'foo1' or (@hippotaxonomy:keys = 'foo2') and
(@hippotaxonomy:keys = 'bar1' or (@hippotaxonomy:keys = 'bar2'))
)] order by @jcr:score descending
My expected query is: (foo1 + foo2) * (bar1 + bar2)
//*[(@hippo:paths='868e22f8-ad19-4b16-ace5-a7cbeea2cc4b' and @hippostd:state='published' and not(@jcr:primaryType='nt:frozenNode')) and
((@hippotaxonomy:keys = 'foo1' or (@hippotaxonomy:keys = 'foo2')) and
(@hippotaxonomy:keys = 'bar1' or (@hippotaxonomy:keys = 'bar2'))
)] order by @jcr:score descending