Skip to contents

Wraps the CKAN package_search action so users can discover datasets that are not in the built-in MORIE catalog and fetch them through morie_fetch_ckan or morie_fetch.

Usage

morie_ckan_search(query, portal = "open.canada.ca", rows = 25L, ...)

Arguments

query

Free-text search string.

portal

A known portal name ("open.canada.ca", "data.ontario.ca", "open.toronto.ca") or a full CKAN base URL (e.g. "https://donnees.montreal.ca").

rows

Maximum number of datasets to return (default 25).

...

Extra named CKAN package_search parameters (e.g. fq = "res_format:CSV", sort = "metadata_modified desc").

Value

A data.frame with one row per resource, columns: dataset_title, dataset_id, resource_id, resource_name, format, datastore_active, url. Feed resource_id into morie_fetch_ckan(resource_id = ...).

Examples

# \donttest{
hits <- try(morie_ckan_search("cannabis survey",
                              portal = "open.canada.ca"))
if (is.data.frame(hits)) {
  head(hits[, c("dataset_title", "resource_id", "format")])
}
#>                             dataset_title                          resource_id
#> 1 Canadian Cannabis Survey 2019 - Summary 6989d788-943f-4586-8aed-115f3f4f790e
#> 2 Canadian Cannabis Survey 2019 - Summary 37e4eb72-b280-4ef3-af97-4eb0923b2637
#> 3  Canadian Cannabis Survey 2021: Summary cac8cff4-774b-47df-8003-0c227aac7b44
#> 4  Canadian Cannabis Survey 2021: Summary 4ef4387f-c8ba-4ba0-ae5a-5be1848ca29b
#> 5  Canadian Cannabis Survey 2020: Summary 818136de-6ebd-4786-9e14-b569638c43ac
#> 6  Canadian Cannabis Survey 2020: Summary 69accb36-122f-4df8-9770-4d3c42dac456
#>   format
#> 1   HTML
#> 2   HTML
#> 3   HTML
#> 4   HTML
#> 5   HTML
#> 6   HTML
# }