blob: 1f50a83dfb6989181b104df171be77d3ab04cd5d [file] [log] [blame]
Marc Kupietzcf1caf42019-09-07 19:19:31 +02001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/KorAPQuery.R
3\name{KorAPQuery}
4\alias{KorAPQuery}
Marc Kupietz62da2b52019-09-12 17:43:34 +02005\title{Send a query to a KorAP connection.}
Marc Kupietzcf1caf42019-09-07 19:19:31 +02006\usage{
Marc Kupietzf568f3f2019-09-16 17:03:46 +02007KorAPQuery(con, query, vc = "", KorAPUrl, metadataOnly = TRUE,
Marc Kupietz25aebc32019-09-16 18:40:50 +02008 ql = "poliqarp", fields = defaultFields, accessRewriteFatal = TRUE,
9 verbose = FALSE)
Marc Kupietzcf1caf42019-09-07 19:19:31 +020010}
11\arguments{
12\item{con}{object obtained from \code{\link{KorAPConnection}}, that contains all necessary connection information}
13
14\item{query}{string that contains the corpus query. The query langauge depends on the \code{ql} parameter. Either \code{query} must be provided or \code{KorAPUrl}}
15
16\item{vc}{string describing the virtual corpus in which the query should be performed. An empty string (default) means the whole corpus, as far as it is license-wise accessible.}
17
18\item{KorAPUrl}{instead of providing the query and vc string parameters, you can also simply copy a KorAP query URL from your browser and use it here (and in \code{KorAPConnection}) to provide all necessary information for the query.}
19
Marc Kupietzb125bdd2019-09-09 12:05:59 +020020\item{metadataOnly}{boolean that determines whether queries should return only metadata without any snippets. This can also be useful to prevent access rewrites. Note that the default value is TRUE, unless the connection is authorized (currently not possible).}
Marc Kupietzb3065522019-09-09 11:34:19 +020021
Marc Kupietz3c531f62019-09-13 12:17:24 +020022\item{ql}{string to choose the query language (see \href{https://github.com/KorAP/Kustvakt/wiki/Service:-Search-GET#user-content-parameters}{section on Query Parameters} in the Kustvakt-Wiki for possible values.}
Marc Kupietzcf1caf42019-09-07 19:19:31 +020023
Marc Kupietzb125bdd2019-09-09 12:05:59 +020024\item{fields}{(meta)data fields that will be fetched for every match}
Marc Kupietz25aebc32019-09-16 18:40:50 +020025
26\item{accessRewriteFatal}{abort if query or given vc had to be rewritten due to insufficent rights (not yet implemented)}
27
28\item{verbose}{print some info}
Marc Kupietzcf1caf42019-09-07 19:19:31 +020029}
Marc Kupietz7bce47d2019-09-09 11:53:11 +020030\value{
Marc Kupietz62da2b52019-09-12 17:43:34 +020031A KorAP query object that, among other information, contains the total number of results in \code{$meta$totalResults}. The resulting object can be used to fetch all query results (with \code{\link{KorAPFetchAll}}) or the next page of results (with \code{\link{KorAPFetchNext}}).
32A correspunding URL to be used within a web browser is contained in \code{$webUIRequestUrl}
33Please make sure to check \code{$collection$rewrites} to see if any unforseen access rewrites of the query's virtual corpus had to be performed.
Marc Kupietz7bce47d2019-09-09 11:53:11 +020034}
Marc Kupietzcf1caf42019-09-07 19:19:31 +020035\description{
Marc Kupietz62da2b52019-09-12 17:43:34 +020036Send a query to a KorAP connection.
Marc Kupietzcf1caf42019-09-07 19:19:31 +020037}
38\examples{
Marc Kupietz3c531f62019-09-13 12:17:24 +020039con <- KorAPConnection()
Marc Kupietzcf1caf42019-09-07 19:19:31 +020040q <- KorAPQuery(con, "Ameisenplage")
Marc Kupietz3c531f62019-09-13 12:17:24 +020041q <- KorAPFetchAll(q)
42summary(q$collectedMatches)
43
Marc Kupietz37b8ef12019-09-16 18:37:49 +020044q <- KorAPQuery(con,
45 KorAPUrl = "https://korap.ids-mannheim.de/?q=Ameise&cq=pubDate+since+2017&ql=poliqarp")
Marc Kupietz3c531f62019-09-13 12:17:24 +020046q$meta$totalResults
Marc Kupietzcf1caf42019-09-07 19:19:31 +020047
Marc Kupietz25aebc32019-09-16 18:40:50 +020048q <- KorAPQuery(con, "Ameisenplage")
49q <- KorAPFetchAll(q, verbose=TRUE)
50tokensPerYear <- function(year) { return(KorAPCorpusStats(con, paste("pubDate in", year))$tokens) }
51df <- as.data.frame(table(as.numeric(format(q$collectedMatches$pubDate,"\%Y")), dnn="year"),
52 stringsAsFactors = FALSE)
53df$ipm <- 1000000 * df$Freq / tokensPerYear(df$year)
54plot(df$year, df$ipm, type="l")
55
Marc Kupietzcf1caf42019-09-07 19:19:31 +020056}
57\references{
58\url{https://ids-pub.bsz-bw.de/frontdoor/index/index/docId/9026}
59}
Marc Kupietz3c531f62019-09-13 12:17:24 +020060\seealso{
61\code{\link{KorAPConnection}}, \code{\link{KorAPFetchNext}}, \code{\link{KorAPFetchRest}}, \code{\link{KorAPFetchAll}}, \code{\link{KorAPCorpusStats}}
62}