Hi Scott,
if I understand you correctly you should be able to request a download with a filter like this one that uses a primary AND nested with some ORs:
"predicate": { "type": "and", "predicates": [ { "type": "or", "predicates": [ { "type": "equals", "key": "TAXON_KEY", "value": "2475470" }, { "type": "equals", "key": "TAXON_KEY", "value": "2475471" }, { "type": "equals", "key": "TAXON_KEY", "value": "2475472" } ] }, { "type": "or", "predicates": [ { "type": "equals", "key": "BASIS_OF_RECORD", "value": "PRESERVED_SPECIMEN" }, { "type": "equals", "key": "FOSSIL_SPECIMEN", "value": "2475471" } ] }, { "type": "equals", "key": "HAS_COORDINATE", "value": "true" }, { "type": "equals", "key": "HAS_GEOSPATIAL_ISSUE", "value": "false" }, { "type": "greaterThanOrEquals", "key": "YEAR", "value": "1949" }, { "type": "lessThanOrEquals", "key": "YEAR", "value": "2011" }, { "type": "greaterThanOrEquals", "key": "MONTH", "value": "3" }, { "type": "lessThanOrEquals", "key": "MONTH", "value": "8" } ] }
Best, Markus
On 13 Jan 2017, at 21:35, Scott Chamberlain <myrmecocystus@gmail.commailto:myrmecocystus@gmail.com> wrote:
Hi!
A rgbif user is asking me about a particular download query, see https://github.com/ropensci/rgbif/issues/245
TLDR: AFAICT this can't work as the API is set up right now. Or am I wrong?
That is, he wants to get data for records that match
- 10 taxa with their taxonKey value - 3 different basisofrecord values - country = US - hasCoordinate = TRUE - hasGeospatialIssue = FALSE - year range between 1949 and 2011 - month range between 3 and 8
For the taxonKey values, I think he needs to combine those with OR operator:
"predicate": { "type": "or", "predicates": [ { "type": "equals", "key": "TAXON_KEY", "value": "2475470" }, { "type": "equals", "key": "TAXON_KEY", "value": "2475470" } ] }
However, he should combine the other parameters (basisofrecord, hasCoordinate, year, month, etc) using AND AFAICT.
BUT, AFAICT the API only allows one predicate key so you can't do what I think is needed here. That is, to say (taxonkey = 1 OR 2 OR 3) + (country = US AND hasCoordinate = true, etc.)
I tried sending two predicate keys in the API and only the second goes through.
Any guidance much appreciated :)
The best solution I can think of is to do the query he's doing, but do one for each taxon. Seem like a good solution?
Best, Scott _______________________________________________ API-users mailing list API-users@lists.gbif.orgmailto:API-users@lists.gbif.org http://lists.gbif.org/mailman/listinfo/api-users