geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
426 stars 489 forks source link

Hierarchical facet search broken #4972

Closed yanus closed 4 years ago

yanus commented 4 years ago

Describe the bug In our installation we are using facets for GEMET Keywords and Regions on the search page, which are being displayed in hierarchical form. When selecting a search term on the second level (e.g. Africa -> Kenya) first, and then any other search term, the query returns no results (even if there are).

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Search'
  2. Expand one of the top level search terms
  3. Click on one of the search terms below it
  4. Click on any other search term
  5. See message about no results

Expected behavior Show the catalog items that match the query (when a top level term is chosen first and then a second level term, the same combination works)

Screenshots image

Queries It seems that there is an encoding issue in the query strings.

This is an example that works (line breaks for better readability): /geonetwork/srv/eng/q?_content_type=json&bucket=s101&facet.q= keyword%2FEconomy %26 region%2Fhttp%253A%252F%252Fwww.naturalearthdata.com%252Fne_admin%2523Continent%252FAfrica%2Fhttp%253A%252F%252Fwww.naturalearthdata.com%252Fne_admin%2523Country%252FRWA &fast=index&from=1&resultType=details&sortBy=changeDate&sortOrder=&to=20

And this doesn't: /geonetwork/srv/eng/q?_content_type=json&bucket=s101&facet.q= region%2Fhttp%253A%252F%252Fwww.naturalearthdata.com%252Fne_admin%2523Continent%252FAfrica,http%253A%252F%252Fwww.naturalearthdata.com%252Fne_admin%2523Country%252FRWA %26 keyword%2FEconomy &fast=index&from=1&resultType=details&sortBy=changeDate&sortOrder=&to=20

Note the comma instead of %2F between the two URLs.

Desktop (please complete the following information):

yanus commented 4 years ago

As a workaround, how can I make those facets display non-hierarchically? (We don't actually need the hierarchy, especially for region, since all our data is from Africa.) I've tried setting the depth parameter in config-summary.xml, but it didn't do anything.

yanus commented 4 years ago

I've added a pull request to fix this issue: #5053

fxprunayre commented 4 years ago

I'm not sure about the issue. Testing on https://sdi.eea.europa.eu/catalogue/ (based on 3.x) GEMET or Regions are working fine. On your screenshot, facet label are not translated which is not normal - maybe an issue with the configuration?

To enable facet on region, diff is:

diff --git a/web/src/main/webResources/WEB-INF/config-spring-geonetwork.xml b/web/src/main/webResources/WEB-INF/config-spring-geonetwork.xml
index de335de882..df596df6aa 100644
--- a/web/src/main/webResources/WEB-INF/config-spring-geonetwork.xml
+++ b/web/src/main/webResources/WEB-INF/config-spring-geonetwork.xml
@@ -175,15 +175,15 @@
   Example configuration for hierarchical facet based on
   the GeoNetwork region thesaurus or GEMET.

-  Do not forget to add facet configuration on config-summary.xml
+  Do not forget to add facet configuration on config-summary.xml-->
+

   <bean id="regionKeywordClassifier"
         class="org.fao.geonet.kernel.search.classifier.TermLabel" lazy-init="true">
     <constructor-arg name="finder" ref="ThesaurusManager"/>
     <constructor-arg name="conceptScheme" value="http://geonetwork-opensource.org/thesaurus/naturalearth-and-seavox"/>
     <constructor-arg name="langCode" value="eng"/>
-  </bean>
-
+  </bean><!--
   <bean id="gemetKeywordClassifier"
         class="org.fao.geonet.kernel.search.classifier.TermLabel" lazy-init="true">
     <constructor-arg name="finder" ref="ThesaurusManager"/>
diff --git a/web/src/main/webapp/WEB-INF/config-summary.xml b/web/src/main/webapp/WEB-INF/config-summary.xml
index 62496308a4..627c04c449 100644
--- a/web/src/main/webapp/WEB-INF/config-summary.xml
+++ b/web/src/main/webapp/WEB-INF/config-summary.xml
@@ -121,10 +121,10 @@

     Do not forget to add classifier configuration on config-spring-geonetwork.xml

-    Then add facet in one summaryType having format="DIMENSION" attribute.
+    Then add facet in one summaryType having format="DIMENSION" attribute.-->
     <facet name="region" label="regions"
            indexKey="keyword"
-           classifier="regionKeywordClassifier"/>
+           classifier="regionKeywordClassifier"/><!--
     <facet name="gemetKeyword" label="gemetKeywords"
            indexKey="keyword"
            classifier="gemetKeywordClassifier"/>
@@ -158,9 +158,9 @@
       <item facet="serviceType"/>
       <item facet="denominator" sortBy="numValue" sortOrder="desc"/>
       <item facet="resolution" sortBy="numValue" sortOrder="desc"/>
-      <!--
       <item facet="region"
             translator="term:http://geonetwork-opensource.org/thesaurus/naturalearth-and-seavox"/>
+      <!--
       <item facet="gemetKeyword"
             translator="term:http://geonetwork-opensource.org/gemet"/>
       -->

As a workaround, how can I make those facets display non-hierarchically?

All thesaurus have a corresponding field in the index. So you can create regular facet using something like:


    <facet name="portail-donnees-facette-type" label="portail-donnees-facette-type" indexKey="thesaurus-local.theme.portail-donnees-facette-type"/>
yanus commented 4 years ago

Dear François, I am able to reproduce the issue on the EEA portal by selecting a hierarchical attribute first and then any other property, as described in my bug report: Screenshot_2020-09-28 https sdi eea europa eu

Thank you for explaining how to add it as a regular facet. Thankfully we were able to fix the original issue on our portal (see my PR).

fxprunayre commented 4 years ago

I am able to reproduce the issue on the EEA portal by selecting a hierarchical attribute first and then any other property, as described in my bug repor

Ok got it. PR approved and merged. Thanks