core-geonetwork
core-geonetwork copied to clipboard
CSW queries should use the draft filter
Otherwise the CSW query returns the approved metadata and it's working copy (for metadata that is approved and has a working copy).
Test case:
-
With the workflow disabled: create an iso19139 metadata with the default template, change the title only.
-
Query in the UI for ISO19115
http://localhost:8080/geonetwork/srv/eng/catalog.search#/search?resultType=details&sortBy=relevance&from=1&to=20&fast=index&_content_type=json&any=ISO19115
Lucene query generated:
+(_op0:0 _op0:-1 _op0:1 _op0:2 _owner:1 _dummy:0) +any:iso19115 +_isTemplate:n +(_draft:n _draft:e) _locale:eng
- Query in CSW for ISO19115
http://localhost:8080/geonetwork/srv/eng/csw?request=GetRecords&service=CSW&version=2.0.2&resultType=results&constraintLanguage=CQL_TEXT&constraint_language_version=1.1.0&outputSchema=IsoRecord&typeNames=csw:Record&constraint=anytext%20like%20%27ISO19115%27
Lucene query generated (the filter doesn't have the _draft field):
+(+(+any:iso19115) +_isTemplate:n _locale:eng) +(_op0:0 _op0:-1 _op0:1 _op0:2 _owner:1)
Results are the same
-
Enable the workflow and create an iso19139 metadata with the default template, change the title only and approve it.
-
Test the queries from 2 and 3)
Results are the same
-
Edit the metadata from 4) to create a working copy
-
Test the queries from 2 and 3)
CSW result returns 3 results instead of 2
This change fixes the previous issue.
The trick maybe due to searching strict keyword vs keywords containing pattern. Here is my finding at my localhost
Search with keyword "file", I have to add a space %20 sign which is constraint=anytext like % file %
http://localhost:8080/geonetwork/srv/eng/csw?request=GetRecords&service=CSW&version=2.0.2&resultType=results&constraintLanguage=CQL_TEXT&constraint_language_version=1.1.0&outputSchema=IsoRecord&typeNames=csw:Record&constraint=anytext%20like%20%27%25%20file%20%25%27
So the two spaces made difference.
I retested the by cherry picking and deploy to our environment. I think the result looks good this time than my localhost testing.
Looks good for me for the change.
I also made a PR (https://github.com/GeoCat/core-geonetwork/pull/51) to fix the unit test