R/run_ksu_search.R

Defines functions run_ksu_search

Documented in run_ksu_search

#' Test of one or more search queries on either the live site or test site.
#' @description
#' Run a test of one or more search queries, using either the live (production) site or the test server.
#' @param term character vector containing search terms
#' @param production (logical) perform search on the production site? default is TRUE
#' @return
#' Dataframe containing the first page of hits for each search query.
#' @export
run_ksu_search <- function(search_terms, production=TRUE){
  docs <- lapply(search_terms,
                 function(x){get_search_contents(x, production=production)$html})

  names(docs) <- search_terms

  results <- docs %>%
    lapply(., extract_result_list) %>%
    lapply(., extract_search_result) %>%
    lapply(., result_dataframe) %>%
    bind_rows(.id="term")

  return(results)
}
kyeager4/ksulibSearch documentation built on May 23, 2019, 9:33 a.m.