Solr connection client

Arguments

host

(character) Host url. Deafault: 127.0.0.1

path

(character) url path.

port

(character/numeric) Port. Default: 8389

scheme

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

proxy

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.

errors

(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.

Value

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

Details

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").

Examples

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 = 'stuff.com') # 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 = "187.62.207.130:3128")) prox <- list(url = "187.62.207.130:3128", user = "foo", pwd = "bar") cli <- SolrClient$new(proxy = prox) cli$proxy # A remote Solr instance to which you don't have admin access (cli <- SolrClient$new(host = "api.plos.org", path = "search", port = NULL)) res <- cli$search(params = list(q = "memory")) res attr(res, "numFound") attr(res, "start") attr(res, "maxScore") }