[opencms-dev] Workplace search not working on 9.5.1

Enrico Marongiu enrico.marongiu at gmail.com
Thu May 7 11:56:33 CEST 2015


Hi everybody,
we have noticed that workplace search is not working correctly (well, as
expected).

Scenario:
Given I have adequate privileges (i.e. admin),
And I select a specific site, i.e "news" (yes, we are in multi-site setup)
on project offline
And I have created a sample content with "sometext" contained in a relevant
field (title, description, body, etc)
When I click the search button and query for "sometext"
Then I expect the search results show the  sample content


Unfortunately, it does not show anything. Digging in the code I found that
a recent fix (9_5_0 is not affected, 9_5_1 is) adds the site root to the
query parameters:

//CmsSearchResourceCollector.java
private CmsSearch getSearchBean(Map<String, String> params) {
[...]
for (int i = 0; i < searchRoots.length; i++) {
    searchRoots[i] = getWp().getCms().addSiteRoot(searchRoots[i]);
}


But this conflicts with the Search Bean, which adds *again* the siteRoot.
//CmsSearchIndex.java
protected BooleanFilter appendPathFilter(CmsObject cms, BooleanFilter
filter, List<String> roots) {
...
String searchRoot = cms.getRequestContext().addSiteRoot(roots.get(i));
...

This is a prospective pull request I would like to start, but before
pushing it I would like your advice ,as this core service may be used by
many more services than i may expect.

//CmsSearchIndex.java

protected BooleanFilter appendPathFilter(CmsObject cms, BooleanFilter
filter, List<String> roots) {

        // complete the search root
        List<Term> terms = new ArrayList<Term>();
        if ((roots != null) && (roots.size() > 0)) {
            // add the all configured search roots with will request context
            for (int i = 0; i < roots.size(); i++) {
                LOG.debug("ENRICO appendPathFilter root PRE(" + i + "): " +
roots.get(i));
                LOG.debug("ENRICO appendPathFilter siteRoot PRE(" + i + "):
" + cms.getRequestContext().getSiteRoot());
//                String searchRoot =
cms.getRequestContext().addSiteRoot(roots.get(i));
                //EM 2015-05-05 These roots are already "getSiteRooted"
                String searchRoot = roots.get(i);
                LOG.debug("ENRICO appendPathFilter siteRoot POST(" + i +
"): " + searchRoot);
                extendPathFilter(terms, searchRoot);
            }

thanks for your patience and time.
Cheers,
Enrico Marongiu


-- 

[image: Enrico Marongiu on about.me]

Enrico Marongiu
about.me/cernio
skype: cerionmorgauin
  <http://about.me/cernio>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20150507/8f783c56/attachment.htm>


More information about the opencms-dev mailing list