Negating an HstQuery Filter - BloomReach Experience - Open Source CMS

This article covers a Hippo CMS version 10. There's an updated version available that covers our most recent release.

15-05-2015

Negating an HstQuery Filter

When you have a Filter with one or more constraints, you can negate() the filter: Negating a filter inverts all the constraints:

String query = ....// create a new Filter
Filter filter = hstQuery.createFilter();
// apply the filter to the hstQuery
hstQuery.setFilter(filter);
// add to the filter a 'query' constraint. "." means to search in the entire
// document
filter.addContains(".", query);
// now, make sure that all the documents that do not contain 'query' are a hit
filter.negate();
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?