bs_search: Search BASE

Description Usage Arguments Details Value Facet Examples

View source: R/bs_search.R

Description

Search BASE

Usage

1
2
3
4
5
6
bs_search(query = NULL, target = NULL, coll = NULL, boost_oa = FALSE,
  hits = NULL, offset = NULL, fields = NULL, sortby = NULL,
  facets = NULL, facet_limit = 100, facet_sort = NULL, raw = FALSE,
  parse = "df", ...)

bs_meta(x)

Arguments

query

(character) query string. For syntax details see Appendix, section "Query syntax"

target

(character) Internal name of a single repository as delivered in bs_repositories()

coll

(character) collection code. For existing, pre-defined collections see Appendix, section "Collection-related queries"

boost_oa

(logical) Push open access documents upwards in the result list. Default: FALSE

hits

(integer) number of results to return. Default: 10. Max: 100

offset

(integer) record to start at. Default: 0. Max: 1000

fields

(character) Fields to return. This doesn't appear to be working though. The result records only contain fields listed in the comma-separated field list. For existing, pre-defined fields see Appendix, section "Fields"

sortby

(character) field to sort by. A sort ordering must include a single field name (see Appendix, section "Fields", table column "Sorting"), followed by a whitespace (escaped as + or followed by sort direction (asc or desc). Default: sorts by relevance

facets

(character) The response contains an extra section "facet_counts/facet_fields" with fields from the comma-separated facets list. This section provides a breakdown or summary of the results. From the user's perspective, faceted search breaks up search results into multiple categories, typically showing counts for each, and allows the user to "drill down" or further restrict their search results based on those facets. Use of faceting does not affect the results section of a search response. For existing, pre-defined facet fields see Appendix, section "Fields", table column "Facet".

facet_limit

(numeric) Maximum number of constraint counts that should be returned for the facet fields. Default: 100; min:1; max: 500

facet_sort

(numeric) Ordering of the facet field constraints: count - sort by count (highest count first); index - alphabetical sorting. Default: count

raw

(logical) If TRUE returns raw XML, default: FALSE

parse

(character) One of 'list' or 'df'

...

Facet field based query options (See Facet below) or curl options passed on to crul::HttpClient()

x

input to bs_meta

Details

BASE asks that requests are not more frequent than 1 per second, so we enforce the rate limit internally. if you do a single request not in a for loop/lapply type situation, this won't be inoked, but will if doing a for loop/lapply call, and there's no sleep invoked

Value

XML as character string if parse = FALSE or data.frame

Facet

You can optionally pass in search term for specific facet fields. See example. For existing, pre-defined facet fields see Appendix at https://www.base-search.net/about/download/base_interface.pdf, section "Fields", table column "Facet"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Not run: 
# repository "ftubbiepub" containing the terms
# "lossau" and "summann" (search in the whole document)
res <- bs_search(target = 'ftubbiepub', query = 'lossau summann')
res
res$dcsubject
res$dccreator
res$dcidentifier
attributes(res)
bs_meta(res)

# Italian repositories containing the term "manghi'
# in the "dccreator" field (author).  The flag "boost" pushes open
# access documents upwards in the result list
(res <- bs_search(coll = 'it', query = 'dccreator:manghi', boost_oa = TRUE))

# terms "schmidt" in dccreator field (author) and "biology" in dctitle.
# The response starts after record 5 (offset=5) and contains max.
# 5 hits with the fields dctitle, dccreator and dcyear
(res <- bs_search(query = 'dccreator:schmidt dctitle:biology',
  hits = 5, offset = 5, fields = c('dctitle', 'dccreator', 'dcyear')))

# term "unix" and published between 1983 and 2009, sorted by year
# of publication (dcyear) in descending order
(res <- bs_search(query = 'unix dcyear:[1983 TO 2009]',
  sortby = 'dcyear desc'))

# raw XML output
bs_search(target = 'ftubbiepub', query = 'lossau summann', raw = TRUE)

# list output
bs_search(target = 'ftubbiepub', query = 'lossau summann', parse = "list")

out <- list()
system.time(
  for (i in 1:3) {
    out[[i]] <- bs_search(target = 'ftubbiepub', query = 'lossau summann',
      hits = 1)
  }
)
out

# Faceting
bs_search(query = "unix", facets = c("dcsubject", "dcyear"),
  facet_limit = 10)

bs_search(query = "unix", facets = c("dcsubject", "dcyear"),
  f_dcsubject = '"computer science"',
  facet_limit = 10, verbose = TRUE)

## End(Not run)

ropenscilabs/rbace documentation built on March 19, 2018, 4:34 p.m.