Solr connection client



(character) Host url. Deafault:


(character) url path.


(character/numeric) Port. Default: 8389


(character) http scheme, one of http or https. Default: http


List of arguments for a proxy connection, including one or more of: url, port, username, password, and auth. See crul::proxy for help, which is used to construct the proxy connection.


(character) One of "simple" or "complete". Simple gives http code and error message on an error, while complete gives both http code and error message, and stack trace, if available.


an object of class auth, created by calling crul::auth()


Various output, see help files for each grouping of methods.


SolrClient creates a R6 class object. The object is not cloneable and is portable, so it can be inherited across packages without complication.

SolrClient is used to initialize a client that knows about your Solr instance, with options for setting host, port, http scheme, and simple vs. complete error reporting

SolrClient methods

Each of these methods also has a matching standalone exported function that you can use by passing in the connection object made by calling SolrClient$new(). Also, see the docs for each method for parameter definitions and their default values.

number of results

When the $search() method returns a data.frame, metadata doesn't fit into the output data.frame itself. You can access number of results (numFound) in the attributes of the results. For example, attr(x, "numFound") for number of results, and attr(x, "start") for the offset value (if one was given). Or you can get all attributes like attributes(x). These metadata are not in the attributes when requesting raw xml or json though as those metadata are in the payload (unless wt="csv").


if (FALSE) { # make a client (cli <- SolrClient$new()) # variables cli$host cli$port cli$path cli$scheme # ping ## ping to make sure it's up cli$ping("gettingstarted") # version ## get Solr version information cli$schema("gettingstarted") cli$schema("gettingstarted", "fields") cli$schema("gettingstarted", "name") cli$schema("gettingstarted", "version")$version # Search cli$search("gettingstarted", params = list(q = "*:*")) cli$search("gettingstarted", body = list(query = "*:*")) # set a different host SolrClient$new(host = '') # set a different port SolrClient$new(host = 3456) # set a different http scheme SolrClient$new(scheme = 'https') # set a proxy SolrClient$new(proxy = list(url = "")) prox <- list(url = "", user = "foo", pwd = "bar") cli <- SolrClient$new(proxy = prox) cli$proxy # set simple authentication details SolrClient$new(auth = crul::auth(user = "hello", pwd = "world")) # A remote Solr instance to which you don't have admin access (cli <- SolrClient$new(host = "", path = "search", port = NULL)) res <- cli$search(params = list(q = "memory")) res attr(res, "numFound") attr(res, "start") attr(res, "maxScore") }