This function retrieves records from the Finna index with an option to limit the total number of records returned. The function paginates through the results, fetching records until the specified total limit is reached.
Usage
search_finna(
query = NULL,
type = "AllFields",
fields = NULL,
filters = NULL,
facets = NULL,
facetFilters = NULL,
sort = "relevance,id asc",
limit = 100,
lng = "fi",
prettyPrint = FALSE
)
Arguments
- query
description
- type
A string specifying the type of search. Options include "AllFields", "Title", "Author", "Subject". Defaults to "AllFields".
- fields
A vector of fields to be returned in the search results. Defaults to NULL, which returns a standard set of fields.
- filters
A vector of filter queries to refine the search. Defaults to NULL.
- facets
A vector specifying which facets to return in the results. Defaults to NULL.
- facetFilters
A vector of regular expressions to filter facets. Defaults to NULL.
- sort
A string defining the sort order of the results. Options include:
"relevance,id asc" (default)
"main_date_str desc" (Year, newest first)
"main_date_str asc" (Year, oldest first)
"last_indexed desc" (Last modified)
"first_indexed desc" (Last added)
"callnumber,id asc" (Classmark)
"author,id asc" (Author)
"title,id asc" (Title)
- limit
An integer specifying the total number of records to return across multiple pages.
- lng
A string for the language of returned translated strings. Options are "fi", "en-gb", "sv", "se". Defaults to "fi".
- prettyPrint
A logical value indicating whether to pretty-print the JSON response. Useful for debugging. Defaults to FALSE.
Value
A tibble containing the search results with relevant fields extracted and provenance information.
Examples
search_results <- search_finna("sibelius", sort = "main_date_str desc", limit = 100)
print(search_results)
#> # A tibble: 100 × 9
#> id Title Author Year Language Formats Subjects Library Series
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 anders.1945667 He s… Kirve… 2024 fin Kirja,… sotilaa… Anders… NA
#> 2 helka.9934642735… Yli-… Frost… 2024 fin Kirja,… Wagner,… Helka-… NA
#> 3 anders.1958752 Eero… Järne… 2024 fin Kirja,… Järnefe… Anders… Atene…
#> 4 helle.1634933 Eero… Järne… 2024 swe Kirja,… Järnefe… Helle-… Atene…
#> 5 helmet.2580197 Eero… Järne… 2024 eng Kirja,… Järnefe… Helmet… Atene…
#> 6 anders.1963289 Sola… NA 2024 zxx Äänite… NA Anders… NA
#> 7 helmet.2584794 Laul… Klas,… 2024 fin Äänite… 2020-lu… Helmet… NA
#> 8 anders.1961626 Nono… Söder… 2024 fin Kirja,… Söderbe… Anders… NA
#> 9 uniarts_print.99… Sola… Sibel… 2024 zxx Äänite… NA Taidey… NA
#> 10 anders.1963284 A ga… Fishe… 2024 eng Äänite… NA Anders… NA
#> # ℹ 90 more rows