SolrClient: Solr connection client

Description Arguments Details Value SolrClient methods number of results Examples

Description

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.

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

Value

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Not run: 
# 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")

## End(Not run)

solrium documentation built on May 19, 2021, 9:06 a.m.