Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt fix csw #275

Merged
merged 3 commits into from
Jan 12, 2024
Merged

Attempt fix csw #275

merged 3 commits into from
Jan 12, 2024

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Jan 11, 2024

Fix Mapstore CSW request.

Only requests on full words works.

Issue

The elasticsearch request is generated with content like :

{
...
query: "%s",
...
query: "%my search%"
...
}

The line changed : String jsonQuery = String.format(elasticSearchQuery, filterQueryString); couldn't handle %m of 'my search'

Solution

Replace all occurences of "%s" by the wanted complement of es request.

Double-quotes have been included to allow search beginning with s. Only a research with %s would be impacted I think.

Curl request to test service :

// on local https://georchestra-127-0-1-1.traefik.me
curl 'https://georchestra-127-0-1-1.traefik.me/geonetwork/srv/fre/csw?service=CSW&version=2.0.2&request=' \
  -H 'authority: georchestra-127-0-1-1.traefik.me' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/xml' \
  -H 'cookie: XSRF-TOKEN=a8308dae-7fc7-43e9-82cc-4c4ea2aa4860; serverTime=1704992499172; sessionExpiry=1704992499172; JSESSIONID=node01wq1jxvsxd6cyr121mwa37uxk0.node0' \
  -H 'origin: https://georchestra-127-0-1-1.traefik.me' \
  -H 'pragma: no-cache' \
  -H 'referer: https://georchestra-127-0-1-1.traefik.me/mapstore/' \
  -H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
  --data-raw $'<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:ows="http://www.opengis.net/ows" service="CSW" version="2.0.2" resultType="results" startPosition="1" maxRecords="4"> <csw:Query typeNames="csw:Record"> <csw:ElementSetName>full</csw:ElementSetName> <csw:Constraint version="1.1.0"> <ogc:Filter> <ogc:And>\n        <ogc:PropertyIsLike wildCard=\'%\' singleChar=\'_\' escapeChar=\'\\\'><ogc:PropertyName>csw:AnyText</ogc:PropertyName> <ogc:Literal>%sol%</ogc:Literal> </ogc:PropertyIsLike> \n        <ogc:Or>\n            <ogc:PropertyIsEqualTo>\n                <ogc:PropertyName>dc:type</ogc:PropertyName>\n                <ogc:Literal>dataset</ogc:Literal>\n            </ogc:PropertyIsEqualTo>\n            <ogc:PropertyIsEqualTo>\n                <ogc:PropertyName>dc:type</ogc:PropertyName>\n                <ogc:Literal>http://purl.org/dc/dcmitype/Dataset</ogc:Literal>\n            </ogc:PropertyIsEqualTo>\n       </ogc:Or>\n    </ogc:And> </ogc:Filter> </csw:Constraint> </csw:Query> </csw:GetRecords>' \
  --compressed

@juanluisrp If interested, it's a use case we've found today.

@f-necas f-necas changed the base branch from georchestra-gn4.2.x to georchestra-gn4.2.x-23.0.x January 11, 2024 17:56
@f-necas f-necas requested review from pmauduit and cmangeat January 11, 2024 18:25
@f-necas f-necas marked this pull request as ready for review January 11, 2024 18:41
@fvanderbiest fvanderbiest added this to the 23.0.6 milestone Jan 12, 2024
@f-necas f-necas requested a review from jeanmi151 January 12, 2024 08:38
Copy link
Contributor

@jeanmi151 jeanmi151 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested in local docker
mapstore can request gn and search for strings

@f-necas f-necas merged commit 2ea70fe into georchestra-gn4.2.x-23.0.x Jan 12, 2024
1 check passed
@f-necas f-necas deleted the attempt-fix-csw branch January 12, 2024 13:42
f-necas added a commit that referenced this pull request Jan 12, 2024
* replace only %s

* feat: replace query with {@}

* feat: replace query with {@}
f-necas added a commit that referenced this pull request Jan 12, 2024
* replace only %s

* feat: replace query with {@}

* feat: replace query with {@}
@f-necas f-necas mentioned this pull request Jan 25, 2024
8 tasks
f-necas added a commit that referenced this pull request Jan 25, 2024
* replace only %s

* feat: replace query with {@}

* feat: replace query with {@}
f-necas added a commit that referenced this pull request Jan 25, 2024
* replace only %s

* feat: replace query with {@}

* feat: replace query with {@}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants