Search only in the current channel (current scope) - 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.

12-05-2015

Search only in the current channel (current scope)

By default, if you do not specify a scope to search in, the search is done over all scopes : Thus all channels, all external sources, etc.

If in your java code, you want to specify to only search below your current channel, you can achieve this as follows:

HippoSolrClient solrClient =
      HstServices.getComponentManager().getComponent(
                    HippoSolrClient.class.getName(), "org.hippoecm.hst.solr");
HippoQuery hippoQuery = solrClient.createQuery(query);
String scope = request.getRequestContext().getResolvedMount().
                               getMount().getCanonicalContentPath();
hippoQuery.setScopes(scope);
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?