Skip to content

Instantly share code, notes, and snippets.

@sckott
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sckott/cf5d2e572faafb4c6d5f to your computer and use it in GitHub Desktop.
Save sckott/cf5d2e572faafb4c6d5f to your computer and use it in GitHub Desktop.
Right now the solr package works with standard Solr input params and output structure. The Europeana input params somewhat match standard Solr input params, so only some work. Output: the output from Europeana isn't standard Solr that I'm used to - so use `parsetype="list"` instead of giving back a data frame

Europeana API via the solr R package

Install solr from github since I pushed a small change to accomodate the query param instead of the typical q param

devtools::install_github("ropensci/solr")
library("solr")

Define the base URL

url <- "http://europeana.eu/api/v2/search.json"

Search for metadata

solr_search(query='Westminster', base = url, wskey='<key>', parsetype = "list", rows = 2)

Gives

http://europeana.eu/api/v2/search.json?rows=2&wt=json&query=Westminster&wskey=<key>
$apikey
[1] "<key>"

$action
[1] "search.json"

$success
[1] TRUE

$requestNumber
[1] 119

$itemsCount
[1] 2

$totalResults
[1] 12250

$items
$items[[1]]
$items[[1]]$id
[1] "/92022/E9FDF1DFE34CAA7B667BF65ACFD87EF0E196537D"

$items[[1]]$completeness
[1] 6

$items[[1]]$europeanaCollectionName
[1] "92022_Ag_EU_TEL_a0430E"

$items[[1]]$index
[1] 0

...cutoff

Search for metadata

solr_search(query='YEAR:[1525 TO 1527]', base = url, wskey='<key>', parsetype = "list", rows = 2)

Gives

http://europeana.eu/api/v2/search.json?rows=2&wt=json&query=YEAR:[1525 TO 1527]&wskey=<key>
$apikey
[1] "<key>"

$action
[1] "search.json"

$success
[1] TRUE

$requestNumber
[1] 121

$itemsCount
[1] 2

$totalResults
[1] 7770

$items
$items[[1]]
$items[[1]]$id
[1] "/08504/0C0F3702A3192793FED95C3CDAD9B37453562120"

$items[[1]]$completeness
[1] 6

$items[[1]]$europeanaCollectionName
[1] "08504_Ag_EU_ATHENA_Ministry_for_Cultural_Heritage_and_Activities"

$items[[1]]$index
[1] 0

...cutoff

Search for metadata

library("plyr")
out <- solr_search(query='Mona Lisa', profile = 'facets', base = url, wskey='<key>', parsetype = "list", rows = 2)
rbind.fill(lapply(out$facets[[1]]$fields, data.frame))

Gives

   label count
1    mul    67
2     de    42
3     en    39
4     it    36
5     nl    25
6     hu    17
7    swe    13
8     sv    12
9     da    11
10    no     6
11    et     5
12    pl     4
13    sk     4
14    fr     3
15    ro     1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment