Tips on using the new solrium R client

There was a question today from a solrium user about switching to the new interface for the solrium package

The new version v1.0 has been out since Nov 2nd

I definitely feel the user’s pain here as it’s very different. We went with a major version bump to v1.0 to help indicate this, in addition to NEWS items etc. Yet not everyone has a chance to look at release notes, etc.

Here’s a few pointers to help switching to using the new solrium:

  1. solr_connect is replaced with SolrClient. solr_connect would set connection options, but you wouldn’t do anything with the output of calling it. With SolrClient you create a connection object (e.g,. cli <- SolrClient$new(...)) and
    a. call functions on that object (e.g., solr_search(cli, ...)), or
    b. pass the connection object to a function (e.g., cli$search(...))
    The interface (parameters, etc.) is the same whether you use (a) or (b).
  2. Because you now create a connection object you can now manage connections to many different Solr instances in the same R session.
  3. To repeat the point, there are two ways to use most functions - Call the function on the connection object or pass the connection object as (usually) the first parameter of a function.
  4. The query functions (search, facet, group, highlight, mlt, stats, all) now all allow user to do a GET or POST http request. To do a GET request, pass parameters to params and to do a POST pass parameters to body. We’ll take care of the rest. Make sure to set your q param if you need it. Since you have to pass a named list with all params to one of params or body, the default of q=*:* is no longer passed if you don’t specify it.
    • body doesn’t have any default values, it’s set to NULL
    • params has a default of list(q = "*:*")
  5. There is now an automatic check for maxRows with functions solr_search/solr_all/solr_mlt to avoid penalty for asking for too many rows. see

Any other tips I should include here?

solrium on github: