I try to create a page with a list of documents and add filtering to the list. Documents structure looks like this:
/content/documents/web/sale-exclusives/
<node name> [web:saleexclusive]
web:exclusive [web:exclusive] (@web:year)
So, there are root documents of type web:saleexclusive
that have compound children of type web:exclusive
with attribute web:year
.
I want to filter documents of type web:saleexclusive
by web:year
attribute of it's child compound node.
To achive this I extend EssentialsListComponent
and override contributeAndFilters
method like this (just for test):
@Override
protected void contributeAndFilters(List<BaseFilter> filters, HstRequest request, HstQuery query) {
Filter filter = query.createFilter();
try {
filter.addGreaterOrEqualThan("web:exclusive/web:year", 1900L);
filters.add(filter);
} catch (FilterException e) {
LOGGER.error("", e);
}
}
The problem is that I'm getting an empty result, although there are documents with web:year > 1900. Without the filter I'm getting all documents under sale-exclusives
.
The filter above produces following XPath query:
//*[(@hippo:paths='79a713cf-294d-4e99-9d63-fc50db10e43f') and (@hippo:availability='live') and not(@jcr:primaryType='nt:frozenNode') and (web:exclusive/web:year >= 1900)] order by @jcr:score descending
Filtering by own attributes of web:saleexclusive
works fine.
How can I fix that?