Skip to contents

Full-text or title search over the A2AJ corpus. The API returns at most 50 hits per call and does not page, so narrow with dataset and the date window rather than asking for more.

Usage

morie_ingest_a2aj_search(
  query,
  search_type = c("full_text", "name"),
  doc_type = c("cases", "laws"),
  size = 10L,
  search_language = c("en", "fr"),
  sort_results = c("default", "newest_first", "oldest_first"),
  dataset = NULL,
  start_date = NULL,
  end_date = NULL,
  timeout = .MORIE_A2AJ_DEFAULT_TIMEOUT,
  user_agent = .MORIE_A2AJ_DEFAULT_UA
)

Arguments

query

Search string. The API accepts its own advanced syntax (quoted phrases, boolean operators); see https://api.a2aj.ca/docs.

search_type

"full_text" (default) or "name" (titles only).

doc_type

"cases" (default) or "laws".

size

Number of hits, 1 to 50.

search_language

"en" (default) or "fr".

sort_results

"default" (relevance with the corpus's court weighting), "newest_first" or "oldest_first".

dataset

Optional character vector of dataset codes to restrict to (for example c("SCC", "ONCA")); see morie_ingest_a2aj_coverage.

start_date, end_date

Optional "YYYY-MM-DD" bounds on the document date.

timeout

HTTP timeout in seconds.

user_agent

User-Agent header sent with the request.

Value

A data.frame, one row per hit, with the record's metadata fields (dataset, citation_en, name_en, document_date_en, url_en, upstream_license, ...) and the search score. Zero rows when nothing matched.

Examples

# \donttest{
hits <- try(morie_ingest_a2aj_search("roncarelli",
  search_type = "name", dataset = "SCC"
))
if (!inherits(hits, "try-error")) hits[, c("citation_en", "name_en")]
#>      citation_en                 name_en
#> 1 [1959] SCR 121 Roncarelli v. Duplessis
# }