Cross-channel content, faceted navigation and HSTQeries

37 views
Skip to first unread message

Uli R

unread,
Oct 25, 2016, 6:01:28 AM10/25/16
to Hippo Community
Hi!

I'm currently dealing with the following hippo setup:

* news entries are saved centrally in one channel
* they are tagged with brands, each brand corresponding to a channel, where it should be available, multiple brands per news entry are possible.
* a faceted navigation is used to filter the news entries in a news list, this works fine, even cross-channel

The problem now arises, that there is also a regular search (a HstQuery over which I have full control), which not only needs to find the news entries but also data local to the channel, like staff information, etc. Because of this, the search is executed in the respective channels.

The intent seems to have been, that the HstQuery treats the faceted navigation like a regular content folder (the faceted navigations are configured in the respective channels) and includes its resultset in the search, this however does NOT work.

My question is what possibilities do I have to fix this

1) Is there a way to create some form of symbolic link to the faceted navigation resultset that is then treated like a regular folder by the search? This would be my favourite solution.
2) Is there a reasonable way to apply the same HstQuery to the faceted navigation where i don't have to merge the two resultsets (from the regular query and the faceted navigation) manually? (i already know https://www.onehippo.org/library/concepts/faceted-navigation/faceted-navigation-combined-with-free-text-search-and-hstqueries.html i did not find it helpful at all, since it seems to decribe the opposite of what i need)
3) what other options am i overlooking?


Best regards, Uli R!

Ard Schrijvers

unread,
Oct 26, 2016, 11:31:19 AM10/26/16
to hippo-c...@googlegroups.com
Hey Uli,

I understand your requirements. You pretty much have two options:

Make sure the HstQuery is injected in the faceted navigation node, see
[1]. Alternatively (I think a more sound solution but you'll need some
assistance because not trivial and unfortunately not yet documented)
would be to differentiate on the content via authorization. Since our
authorization model is accounted for in queries as well, it would work
very well for your use case. In the frontend delivery, you'd then
based on which channel is hit, use a different hst session pool (with
the correct read access for that channel). For this setup, you also
change the 'root folder' for all channels one level higher on the
mount, and account for the 'root folder' in the sitemap. As said, for
this setup you'd require some professional Hippo assistance (it is too
much for me on the public list)

HTH,

Regards Ard

[1] https://www.onehippo.org/library/concepts/faceted-navigation/faceted-navigation-combined-with-free-text-search-and-hstqueries.html
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hippo-communi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.



--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

ulrich...@gmail.com

unread,
Oct 27, 2016, 5:00:37 AM10/27/16
to Hippo Community
Hey Ard,

So i assume linking the faceted navigation to a folder is an absolute impossibility since you didn't mention it at all?

But okay, since it isn't documented the authorization model is out of the question, but in regards to the injection of the hst query in the faceted navigation:

This still leaves me with the problem of manually having to merge the resultsets of the faceted navigation (even with the hstquery injected) and the hstquery (which has to be executed in the local channel), which is just dirty because of sorting the resultset for example (sorting should be done in the query, not manually in code). So instead of injecting the hstquery into the faceted navigation, i need a way for the to either inject the faceted navigation somehow into the hstQuery or make the hstQuery include the facnav resultset in the search - are there really no possibilities to do this?

Best reagards, Uli

ulrich...@gmail.com

unread,
Nov 2, 2016, 11:49:21 AM11/2/16
to Hippo Community, ulrich...@gmail.com
Since there was no further reply i implemented my own covenience-method which does what we require:


/**
 * Injects the docbase and basefilters of a faceted navigation bean into an existing HstQuery
 * @param query the query to be modified
 * @param facNav the faceted navigation to be injected into the query
 * @return the modified query (if everything went right ^^)
 */
public static HstQuery injectFacNavIntoQuery(HstQuery query, HippoFacetNavigation facNav) {
   
String facetDocBaseUUID = facNav.getProperty("hippo:docbase");
    HippoBean facetDocBase = facNav.getBeanByUUID(facetDocBaseUUID, HippoBean.class);
    if (facetDocBase != null) {
       
ArrayList<HippoBean> tmplist = new ArrayList<>();
        tmplist.add(facetDocBase);
        query.addScopes(tmplist);
        String[] facNavFilters = facNav.getProperty("hippofacnav:filters");
        if (facNavFilters != null && facNavFilters.length > 0) {
           
Filter filter = query.createFilter();
            try {
               
Filter hippoPathsFilter = query.createFilter();
                hippoPathsFilter.addEqualTo("@hippo:paths", facetDocBaseUUID);
                hippoPathsFilter.negate();
                filter.addAndFilter(hippoPathsFilter);
                Filter orFilter = query.createFilter();
                for (String facNavFilter: facNavFilters)
               
{
                    orFilter
.addJCRExpression(facNavFilter);
                }
                filter
.addOrFilter(orFilter);
                query.setFilter(filter);
            } catch (FilterException e) {
                e
.printStackTrace();
            }
       
}
   
}
   
return query;
}


It works for our usecase but i was careful to implement it as generally as possible, so i hope it's also of help to other people with a similar problem.

Please inform me If you notice anything "wrong" (i.e. if i need to expect unwanted side effects, that i might not have thought of - e.g. i wasn't sure if a can add all possible "hippofacnav:filters" values as JCRExpressions into a filter)

Best regards, Uli!

Ard Schrijvers

unread,
Nov 3, 2016, 5:22:31 AM11/3/16
to hippo-c...@googlegroups.com, ulrich...@gmail.com
Hey Uli,

as long as you realize that 'facNavFilter' in your code coming from
the fac nav node does not always (I think almost never) contain valid
'jcr expressions'.

Thanks for sharing your solution,

Regards Ard

[1] https://www.onehippo.org/library/concepts/faceted-navigation/faceted-navigation-configuration.html
Reply all
Reply to author
Forward
0 new messages