Add example for querying metadata of text within a vc
Change-Id: If2cd08c87374dff690e24ee4498e640fe2e3a2b8
diff --git a/R/KorAPQuery.R b/R/KorAPQuery.R
index 45425b6..f04e59d 100644
--- a/R/KorAPQuery.R
+++ b/R/KorAPQuery.R
@@ -476,15 +476,15 @@
# Build the query with the appropriate count and offset using httr2
count_param <- min(if (!is.na(maxFetch)) maxFetch - results else maxResultsPerPage, maxResultsPerPage)
-
+
# Parse existing URL to preserve all query parameters
parsed_url <- httr2::url_parse(kqo@requestUrl)
existing_query <- parsed_url$query
-
+
# Add/update count and offset parameters
existing_query$count <- count_param
existing_query$offset <- currentOffset
-
+
# Rebuild the URL with all parameters
query <- httr2::url_modify(kqo@requestUrl, query = existing_query)
res <- apiCall(kqo@korapConnection, query)
@@ -700,11 +700,26 @@
#'
#' @examples
#' \dontrun{
-#'
-#' q <- KorAPConnection() %>%
-#' corpusQuery("Ameisenplage") %>%
+#' # Fetch all metadata of every query hit for "Ameisenplage" and show a summary
+#' q <- KorAPConnection() |>
+#' corpusQuery("Ameisenplage") |>
#' fetchAll()
#' q@collectedMatches
+#'
+#' # Fetch also all KWICs
+#' q <- KorAPConnection() |> auth() |>
+#' corpusQuery("Ameisenplage", metadataOnly = FALSE) |>
+#' fetchAll()
+#' q@collectedMatches
+#'
+#' # Retrieve title and text sigle metadata of all texts published on 1958-03-12
+#' q <- KorAPConnection() |>
+#' corpusQuery("<base/s=t>", # this matches each text once
+#' vc = "pubDate in 1958-03-12",
+#' fields = c("textSigle", "title"),
+#' ) |>
+#' fetchAll()
+#' q@collectedMatches
#' }
#'
#' @aliases fetchAll