Skip to contents

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 × 8
#>    Title                   Author Year  Language Formats Subjects Library Series
#>    <chr>                   <chr>  <chr> <chr>    <chr>   <chr>    <chr>   <chr> 
#>  1 He selvisivät sodasta   Kirve… 2024  fin      Kirja,… sotilaa… Anders… NA    
#>  2 Yli-ihmisiä ja traagis… Frost… 2024  fin      Kirja,… Wagner,… Helka-… NA    
#>  3 Eero Järnefelt          Järne… 2024  fin      Kirja,… Järnefe… Anders… Atene…
#>  4 Eero Järnefelt          Järne… 2024  swe      Kirja,… Järnefe… Helle-… Atene…
#>  5 Eero Järnefelt          Järne… 2024  eng      Kirja,… Järnefe… Helmet… Atene…
#>  6 Solace                  NA     2024  zxx      Äänite… NA       Anders… NA    
#>  7 Laulun juhlaa           Klas,… 2024  fin      Äänite… 2020-lu… Helmet… NA    
#>  8 Solace                  Sibel… 2024  zxx      Äänite… NA       Taidey… NA    
#>  9 A gardener's world : f… Fishe… 2024  eng      Äänite… NA       Anders… NA    
#> 10 Sibelius, Prokofiev 1,… Janse… 2024  zxx      Äänite… NA       Eepos-… NA    
#> # ℹ 90 more rows