SolrSchema-class {rsolr} | R 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 aFieldInfo
object, restricted to the fields indicated bywhich
. -
fieldTypes(x, fields)
: Gets aFieldTypeList
object, containing the type definition for each field named infields
. -
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 aSolrSchema
from a data.frame (or data.frame-coercible)x
. Thename
is taken by quotingx
, by default. Specify a unique key viauniqueKey
. Therequired
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). Theindexed
andstored
arguments name the fields that should be indexed and stored, respectively (see Solr docs for details). IfincludeVersionField
isTRUE
, 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. SeesaveXML
for more details.
Author(s)
Michael Lawrence