Executes a ServCat Advanced Search using a POST request. Search criteria are posted in the request body, while paging and sorting parameters are sent as URI query parameters.
Usage
search_references(
criteria,
top = 25,
page = 1,
orderby = NULL,
sort = NULL,
composite = FALSE,
all_pages = FALSE,
secure = FALSE,
api_key = NULL
)Arguments
- criteria
A named list of Advanced Search criteria. Supported top-level fields include:
quickSearchA character string to search using ServCat Quick Search. If supplied, Quick Search is the primary source of results, and other filters are applied to those results.
visibilityOptional visibility filter. Use
"public"to return only public records,"internal"to return only internal records, orNULLto omit the visibility filter. Non-secure services can return only public records.legacyOptional legacy-status filter. Use
"excludelegacy"to return only non-legacy records,"onlylegacy"to return only legacy records, orNULLto omit the legacy filter.versionOptional version filter. Use
"all"to include all versions of versioned records, orNULLto omit the version filter.regionsA list of Region filters. Each entry may include
order,logicOperator, andunitCode.unitsA list of Unit filters. Each entry may include
order,logicOperator,unitCode,linked, andapproved.textFieldsA list of text-field filters. Each entry may include
order,logicOperator,fieldName, andsearchText. ValidfieldNamevalues include"Abstract","Notes","TableOfContent","ContactName","Publisher","Keyword","MiscellaneousCode","Title", and"DisplayCitation".datesA list of date filters. Each entry may include
order,logicOperator,fieldName,filter,startDate, andendDate. ValidfieldNamevalues include"DateOfIssue","ContentBeginDate","ContentEndDate","LastEdited", and"DateCreated". Validfiltervalues include"BeforeDate","AfterDate","BetweenDates","Exactly","NotEquals", and"NotBetween".referenceTypesA list of Reference Type filters. Each entry may include
order,logicOperator, andreferenceType.referenceGroupsA list of Reference Type Group filters. Each entry may include
order,logicOperator, andgroup.rectanglesOne or more bounding boxes represented as OGC Well-Known Text polygon strings, for example
"POLYGON((-121.8 45.7,-116.4 45.7,-116.4 42.0,-121.86 42.0,-121.8 45.7))".subjectCategoriesA list of Subject Category filters. Each entry may include
order,logicOperator, andsubjectCategory, wheresubjectCategoryis a numeric Subject Category identifier.digitalResourcesA list of Files and Links filters. Each entry may include
order,logicOperator,type,fieldName, andsearchText. Validtypevalues include"DigitalFile","ExternalLink", and"WebService".physicalCopiesA list of Physical Copy filters. Each entry may include
order,logicOperator,unitCode, andsearchText.collectionsA list of Saved Collection filters. Each entry may include
order,logicOperator, andcollection, wherecollectionis a numeric Saved Collection identifier.peopleA list of Owner or Creator filters. Each entry may include
order,logicOperator,fieldName, andsearchText. ValidfieldNamevalues include"Creator"and"Owner". ThesearchTextvalue should be a staff UPN or partner user code.
For criteria sections that accept multiple entries,
logicOperatorcan be used to combine or exclude criteria. Common values include"AND","OR", and"NOT". Group operators such as"ANDGROUP","ORGROUP", and"NOTGROUP"may be used where supported by the ServCat API.- top
Number of entries per page. Defaults to
25. Use a larger integer, such as1000, to reduce paging, but avoid values so large that the request may time out.- page
One-based page index to return. Defaults to
1. Ifall_pages = TRUE, this is the first page requested.- orderby
Optional name of a single field by which to sort results.
- sort
Optional sort direction. Must be
"ASC"or"DESC"if supplied.- composite
Logical. If
TRUE, use the composite Advanced Search endpoint, which returns additional nested detail such as linked resources and associated units. Defaults toFALSE.- all_pages
Logical. If
TRUE, request pages sequentially starting withpageand combine results into one tibble. Defaults toFALSE.- secure
Logical. Use the secure API?
- api_key
Optional secure API key. If omitted, the package API-key helper is used for secure requests.
Value
A tibble of Advanced Search result items. Page metadata from the
response is stored in the "page_detail" attribute. When
all_pages = TRUE, "page_detail" is a list containing page metadata for
each requested page. When composite = TRUE, the returned tibble may
include list-columns such as linkedResources and units.
Examples
if (FALSE) { # \dontrun{
# Quick Search using the Advanced Search endpoint
results <- search_references(
criteria = list(
quickSearch = "Kodiak, goats"
)
)
results
# View paging metadata
attr(results, "page_detail")
# Request more results per page
results <- search_references(
criteria = list(
quickSearch = "Kodiak, goats"
),
top = 100
)
# Retrieve all result pages
all_results <- search_references(
criteria = list(
quickSearch = "Kodiak, goats"
),
top = 100,
all_pages = TRUE
)
# Return composite results with linked resources and units
composite_results <- search_references(
criteria = list(
quickSearch = "Kodiak, goats"
),
composite = TRUE
)
# Search public records and sort by issue date
results <- search_references(
criteria = list(
quickSearch = "Kodiak, goats",
visibility = "public"
),
top = 100,
page = 1,
orderby = "dateOfIssue",
sort = "DESC"
)
# Search by reference type. NULL fields are omitted from the request body.
reports <- search_references(
criteria = list(
referenceTypes = list(
list(
order = 1,
logicOperator = NULL,
referenceType = "Unpublished Report"
)
)
)
)
# Search within title text
title_results <- search_references(
criteria = list(
textFields = list(
list(
order = 1,
logicOperator = NULL,
fieldName = "Title",
searchText = "mountain goat"
)
)
)
)
# Search by date range
date_results <- search_references(
criteria = list(
dates = list(
list(
order = 1,
logicOperator = NULL,
fieldName = "DateOfIssue",
filter = "BetweenDates",
startDate = "2010-01-01",
endDate = "2020-12-31"
)
)
)
)
# Search for records with public digital files
file_results <- search_references(
criteria = list(
digitalResources = list(
list(
order = 1,
logicOperator = NULL,
type = "DigitalFile",
fieldName = NULL,
searchText = NULL
)
)
)
)
} # }
