gbif / portal16

GBIF.org website
https://www.gbif.org
Apache License 2.0
24 stars 15 forks source link

JSON output (API) from an occurrence download does not work in the occurrence download tool #1857

Closed gbif-portal closed 1 year ago

gbif-portal commented 1 year ago

JSON output (API) from an occurrence download does not work in the occurrence download tool

Some predicate key and values seems to not be supported currently in the occurrence download tool: https://www.gbif.org/occurrence/download/request

Take for example this download, the "matchCase": false key and value pair in the predicate

"type": "lessThan",
          "key": "COORDINATE_UNCERTAINTY_IN_METERS",
          "value": "10000",
          "matchCase": false

will lead to an invalid filter in the tool.

Ideally, the API occurrence download filters should be copy-pasteable into the tool, without having to troubleshoot why the applied filter does not work.


Github user: @CecSve User: See in registry - Send email System: Firefox 112.0.0 / Windows 10.0.0 Referer: https://www.gbif.org/occurrence/download/0196117-230224095556074 Window size: width 1600 - height 773 API log&_a=(columns:!(_source),filters:!(),index:'3390a910-fcda-11ea-a9ab-4375f2a9d11c',interval:auto,query:(language:kuery,query:''),sort:!())) Site log&_a=(columns:!(_source),filters:!(),index:'5c73f360-fce3-11ea-a9ab-4375f2a9d11c',interval:auto,query:(language:kuery,query:''),sort:!())) System health at time of feedback: OPERATIONAL

MortenHofft commented 1 year ago

I'm removing API label and adding portal16. The issue is that the portal tries to validate that it is legal. The page is intended to serve the hosted portals. Which never sends matchcase params. Secondly the matchcase param was added to the API after the page/validator was created.

just curious: Why/how are you using it? Is it just because you find it convenient over using the API?

MortenHofft commented 1 year ago

@fmendezh do we have an endpoint to validate predicates without triggering a download? Currently the portal has been using its own valdiator, which is now stale

UDPDATE: I just realise that I could use the new search by predicate API as a way to test validity, let me know if there is a better way

CecSve commented 1 year ago

just curious: Why/how are you using it? Is it just because you find it convenient over using the API?

Yes, for convenience. For users new to the API and who are not comfortable working in R or Python we highlight the tool as an option. At a workshop earlier this week, we made the participants aware of the JSON view of a download and how they could use it as a template to build a query in the tool, but then realized it sometimes led to an invalid filter error message. For such users, it may be difficult to trouble shoot the solution, so if possible, it would be great if API filters from previous downloads would work in the tool or provide more information on the issues.

MortenHofft commented 1 year ago

what does match case mean for a lessThan filter? isn't this a bug in the input? This might be more of a question to you @fmendezh

So far I only accept it for like, in and equals predicates. I can add it to lessThan of course, but it looks like it doesn't belong there in the first instance

MortenHofft commented 1 year ago

I've made it more forgiving, so it now accepts it for e.g. lessThan, but I think it is weird. But given that we have been issuing those it might be a good idea to generously accept them for now - so that it is somewhat consistent

MortenHofft commented 1 year ago

matchcase added in https://github.com/gbif/portal16/commit/7f71945502714724dd66207a56fba3166266cc2d

CecSve commented 1 year ago

I just noticed that the matchCase does not work for other predicates as well when using pygbif to make the API query. Could the issue be that the matchCase is not really working in API but for some default reason is added in the API download output of an occurrence download (like here)? I can see it is used in examples in the doc, but my original query did not contain matchCases and copy-pasting the API output into a new query fails because of the added matchCase @fmendezh