1,554
edits
(add links to images →Advanced Elasticsearch Examples) |
|||
Line 1,072: | Line 1,072: | ||
# "hasImage" is true | # "hasImage" is true | ||
# "county" is either "Hocking" or "Fairfield" | # "county" is either "Hocking" or "Fairfield" | ||
# "stateprovince" is | # "stateprovince" is "Ohio" (there are multiple Fairfield counties throughout the world so we need to restrict the geography by state) | ||
The essential query parameter string will look something like this: | The essential query parameter string will look something like this (note we must lowercase the values): | ||
<pre> | <pre> | ||
Line 1,080: | Line 1,080: | ||
</pre> | </pre> | ||
In addition, it is possible to request more or fewer records at a time using the "from" and "size" parameters. Below is the full curl example requesting only the first 3 records and grep | In addition, it is possible to request more or fewer records at a time using the "from" and "size" parameters. Below is the full curl example requesting only the first 3 records and using grep on the output to filter everything except the iDigBio UUID field. Note that we quote the full URL to keep the shell from trying to interpret the special characters. | ||
<pre> | <pre> | ||
$ curl -s | $ curl -s 'http://search.idigbio.org/idigbio/records/_search?from=0&size=3&q=hasImage:true+AND+county:(fairfield+OR+hocking)+AND+stateprovince:ohio' | json_pp | egrep "\"uuid\"" | ||
"uuid" : "ecf14f53-d225-4eb5-89e6-66379b360781", | |||
"uuid" : "e45071cd-40eb-41e7-9105-0e35234025f5", | |||
"uuid" : "20ad60a8-4126-4cc0-9378-411a9a640005", | "uuid" : "20ad60a8-4126-4cc0-9378-411a9a640005", | ||
</pre> | </pre> | ||
Now that we have iDigBio UUIDs, we could retrieve images for these specimens by iterating over the /media endpoints for each of those uuids in the API. | Now that we have iDigBio UUIDs, we could retrieve images for these specimens by iterating over the /media endpoints for each of those uuids in the API. | ||
http://api.idigbio.org/v1/records/ | http://api.idigbio.org/v1/records/ecf14f53-d225-4eb5-89e6-66379b360781/media?quality=webview | ||
http://api.idigbio.org/v1/records/ | http://api.idigbio.org/v1/records/e45071cd-40eb-41e7-9105-0e35234025f5/media?quality=webview | ||
... | ... | ||
Note that we did not specify any sorting in the Elasticsearch query and restricted the result count using the "size" parameter. If the same query is run at a later time the specific records returned could be different. | |||
; 2. We plan to continue adding examples to this page... | ; 2. We plan to continue adding examples to this page... |
edits