SolrSchema-class: SolrSchema

SolrSchema-classR Documentation

SolrSchema

Description

The SolrSchema object represents the schema of a Solr core. Not all of the information in the schema is represented; only the relevant elements are included. The user should not need to interact with this class very often.

One can infer a SolrSchema from a data.frame with deriveSolrSchema and then write it out to a file for use with Solr.

Accessors

  • name(x): Gets the name of the schema/dataset.

  • uniqueKey(x): Gets the field that serves as the unique key, i.e., the document identifier.

  • fields(x, which): Gets a FieldInfo object, restricted to the fields indicated by which.

  • fieldTypes(x, fields): Gets a FieldTypeList object, containing the type definition for each field named in fields.

  • copyFields(x): Gets the copy field relationships as a graph.

Generation and Export

It may be convenient for R users to autogenerate a Solr schema from a prototypical data frame. Note that to harness the full power of Solr, it pays to get familiar with the details. After deriving a schema with deriveSolrSchema, save it to the standard XML format with saveXML. See the vignette for an example.

  • deriveSolrSchema(x, name, version="1.5", uniqueKey=NULL, required=colnames(Filter(Negate(anyEmpty), x)), indexed=colnames(x), stored=colnames(x), includeVersionField=TRUE): Derives a SolrSchema from a data.frame (or data.frame-coercible) x. The name is taken by quoting x, by default. Specify a unique key via uniqueKey. The required fields are those that are not allowed to contain missing/empty values. By default, we guess that a field is required if it does not contain any NAs or empty strings (both are the same as far as Solr is concerned). The indexed and stored arguments name the fields that should be indexed and stored, respectively (see Solr docs for details). If includeVersionField is TRUE, the magic _version_ field is added to the schema, and Solr will use it to track document versions, which is needed for certain advanced features and generally recommended.

  • saveXML(doc, file = NULL, compression = 0, indent = TRUE, prefix = "<?xml version=\"1.0\"?>\n", doctype = NULL, encoding = getEncoding(doc), ...): Writes the schema to XML. See saveXML for more details.

Author(s)

Michael Lawrence


lawremi/rsolr documentation built on May 28, 2022, 6:17 a.m.