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

error mapstore when requesting geonetwork catalog #249

Closed
jeanmi151 opened this issue Aug 28, 2023 · 4 comments
Closed

error mapstore when requesting geonetwork catalog #249

jeanmi151 opened this issue Aug 28, 2023 · 4 comments

Comments

@jeanmi151
Copy link
Contributor

jeanmi151 commented Aug 28, 2023

Describe the bug
Error when using mapstore listing CSW

To Reproduce
Steps to reproduce the behavior:

  1. start docker composition on latest
  2. open mapstore
  3. add layer using the local geonetwork catalogues
  4. image

reproduce with curl

$ 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,fr;q=0.8' \
  -H 'content-type: application/xml' \
  -H 'cookie: XSRF-TOKEN=b6834109-bc50-498a-988c-fa84d13010f7; serverTime=1693216725966; sessionExpiry=1693216725966; JSESSIONID=node0bah7ops4ompu1p5mnqiuwsjdd0.node0' \
  -H 'origin: https://georchestra-127-0-1-1.traefik.me' \
  -H 'referer: https://georchestra-127-0-1-1.traefik.me/mapstore/' \
  -H 'sec-ch-ua: "Not)A;Brand";v="24", "Chromium";v="116"' \
  -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/116.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: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> </ogc:Filter> </csw:Constraint> </csw:Query> </csw:GetRecords>' \
  --compressed
<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2.0" xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd">
  <ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>java.lang.RuntimeException: ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>
@pmauduit
Copy link
Member

Here is a sample raw response from Elasticsearch when the error occurs:

{
   "error" : {
      "failed_shards" : [
         {
            "index" : "gn-records",
            "node" : "xxx",
            "reason" : {
               "caused_by" : {
                  "caused_by" : {
                     "reason" : "Lexical error at line 1, column 36.  Encountered: <EOF> after : \"/Dataset\"",
                     "type" : "token_mgr_error"
                  },
                  "reason" : "Cannot parse 'http://purl.org/dc/dcmitype/Dataset': Lexical error at line 1, column 36.  Encountered: <EOF> after : \"/Dataset\"",
                  "type" : "parse_exception"
               },
               "index" : "gn-records",
               "index_uuid" : "aaa",
               "reason" : "Failed to parse query [http://purl.org/dc/dcmitype/Dataset]",
               "type" : "query_shard_exception"
            },
            "shard" : 0
         }
      ],
      "grouped" : true,
      "phase" : "query",
      "reason" : "all shards failed",
      "root_cause" : [
         {
            "index" : "gn-records",
            "index_uuid" : "aaa",
            "reason" : "Failed to parse query [http://purl.org/dc/dcmitype/Dataset]",
            "type" : "query_shard_exception"
         }
      ],
      "type" : "search_phase_execution_exception"
   },
   "status" : 400
}

And here is the request being sent to ES by GN (base64 decoded):

{
   "bool" : {
      "filter" : {
         "query_string" : {
            "query" : "*:* AND (isTemplate:n) AND (draft:n OR draft:e)"
         }
      },
      "minimum_should_match" : 1,
      "should" : [
         {
            "query_string" : {
               "fields" : [
                  "resourceType"
               ],
               "query" : "http://purl.org/dc/dcmitype/Dataset"
            }
         },
         {
            "query_string" : {
               "fields" : [
                  "resourceType"
               ],
               "query" : "dataset"
            }
         }
      ]
   }
}

@pmauduit
Copy link
Member

Using:

--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: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> </ogc:Filter> </csw:Constraint> </csw:Query> </csw:GetRecords>' \

makes the previous curl payload work.

@pmauduit
Copy link
Member

pmauduit commented Aug 28, 2023

Maybe the issue is coming from mapstore, the following payload is indeed sent to geonetwork:

<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:Or>
            <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>dc:type</ogc:PropertyName>
                <ogc:Literal>dataset</ogc:Literal>
            </ogc:PropertyIsEqualTo>
            <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>dc:type</ogc:PropertyName>
                <ogc:Literal>http://purl.org/dc/dcmitype/Dataset</ogc:Literal>
            </ogc:PropertyIsEqualTo>
       </ogc:Or> </ogc:Filter> </csw:Constraint> </csw:Query> </csw:GetRecords>

I don't get why the second PropertyIsEqualTo is necessary, it looks pretty similar to the first one, maybe this is to comply with several CSW implementations ?

@f-necas f-necas mentioned this issue Jan 9, 2024
@landryb
Copy link
Member

landryb commented Jan 16, 2024

closed by #274

@landryb landryb closed this as completed Jan 16, 2024
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

No branches or pull requests

3 participants