SolrCore-class: SolrCore

SolrCore-classR Documentation

SolrCore

Description

The SolrCore object represents a core hosted by a Solr instance. A core is essentially a queryable collection of documents that share the same schema. It is usually not necessary to interact with a SolrCore directly.

Details

The typical usage (by advanced users) would be to construct a custom SolrQuery and execute it via the docs, facets or (the very low-level) eval methods.

Accessor methods

In the code snippets below, x is a SolrCore object.

  • name(x): Gets the name of the core (specified by the schema).

  • ndoc(x, query = SolrQuery()): Gets the number of documents in the core, given the query restriction.

  • schema(x): Gets the SolrSchema satisfied by all documents in the core.

  • fieldNames(x, query = NULL, onlyStored = FALSE, onlyIndexed = FALSE, includeStatic = FALSE): Gets the field names, given any restriction and/or transformation in query, which is a SolrQuery or a character vector of field patterns. The onlyIndexed and onlyStored arguments restrict the fields to those indexed and stored, respectively (see FieldInfo for more details). Setting includeStatic to TRUE ensures that all of the static fields in the schema are returned.

  • version(x): Gets the version of the Solr instance hosting the core.

Constructor

  • SolrCore(uri, ...): Constructs a new SolrCore instance, representing a Solr core located at uri, which should be a string or a RestUri object. If a string, then the ... are passed to the RestUri constructor.

Reading

  • docs(x, query = SolrQuery(), as=c("list", "data.frame")): Get the documents selected by query, in the form indicated by as, i.e., either a list or a data frame.

  • read(x, ...): Just an alias for docs.

Summarizing

  • facets(x, by, ...): Gets the Facets results as requested by by, a SolrQuery. The ... are passed down to facets on ListSolrResult.

  • groupings(x, by, ...): Gets the list of Grouping objects as requested by the grouped query by. The ... are passed down to groupings on ListSolrResult.

  • ngroup(x): Gets the number of groupings that would be returned by groupings.

Updating

  • update(object, value, commit = TRUE, atomic = FALSE, ...): Load the documents in value (typically a list or data frame) into the SolrCore given by object. If commit is TRUE, we request that Solr commit the changes to its index on disk, with arguments in ... fine-tuning the commit (see commit). If atomic is TRUE, then the existing documents are modified, rather than replaced, by the documents in value.

  • delete(x, which = SolrQuery(), ...): Deletes the documents specified by which (all by default), where the ... are passed down to update.

  • commit(x, waitSearcher=TRUE, softCommit=FALSE, expungeDeletes=FALSE, optimize=TRUE, maxSegments=if (optimize) 1L): Commits the changes to the Solr index; see the Solr documentation for the meaning of the parameters.

  • purgeCache(x): Purges the client-side HTTP cache, which is useful if the Solr instance is using expiration-based HTTP caching and one needs to see the result of an update immediately.

Evaluation

  • eval(expr, envir, enclos): Evaluates the query expr in the core envir, ignoring enclos. Unless otherwise requested by the query response type, the result should be returned as a ListSolrResult.

Coercion

  • as.data.frame(x, row.names=NULL, optional=FALSE, ...):

Author(s)

Michael Lawrence

See Also

SolrFrame, the typical way to interact with a Solr core.

Examples


     solr <- TestSolr()
     sc <- SolrCore(solr$uri)
     name(sc)
     ndoc(sc)

     delete(sc)
     
     docs <- list(
        list(id="2", inStock=TRUE, price=2, timestamp_dt=Sys.time()),
        list(id="3", inStock=FALSE, price=3, timestamp_dt=Sys.time()),
        list(id="4", price=4, timestamp_dt=Sys.time()),
        list(id="5", inStock=FALSE, price=5, timestamp_dt=Sys.time())
     )
     update(sc, docs)

     q <- SolrQuery(id %in% as.character(2:4))
     read(sc, q)

     solr$kill()


rsolr documentation built on May 18, 2022, 9:07 a.m.