core-geonetwork icon indicating copy to clipboard operation
core-geonetwork copied to clipboard

CSW queries should use the draft filter

Open josegar74 opened this issue 2 years ago • 2 comments

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:

  1. With the workflow disabled: create an iso19139 metadata with the default template, change the title only.

  2. 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
  1. 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

  1. Enable the workflow and create an iso19139 metadata with the default template, change the title only and approve it.

  2. Test the queries from 2 and 3)

Results are the same

  1. Edit the metadata from 4) to create a working copy

  2. Test the queries from 2 and 3)

CSW result returns 3 results instead of 2


This change fixes the previous issue.

josegar74 avatar Jul 12 '22 12:07 josegar74

The trick maybe due to searching strict keyword vs keywords containing pattern. Here is my finding at my localhost

image

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.

wangf1122 avatar Jul 12 '22 14:07 wangf1122

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

wangf1122 avatar Jul 19 '22 15:07 wangf1122