About Features Downloads Getting Started Documentation Events Support

Site Tools


legacy:vufind_1.x_developer_manual:supporting_a_new_metadata_format

Support for New Record Formats

This page refers to VuFind 1.x; for documentation on newer versions, see the VuFind 2.x version of the page.

Note: This feature was introduced in VuFind 1.0. If you are using VuFind 1.0RC2 or earlier, please upgrade to gain access to this functionality.

Introduction

VuFind is currently bundled with a standard indexer (SolrMarc) that handles MARC records quickly and efficently. However, VuFind also has the capability to support any other form of metadata if you are willing to do at least one of two things:

  • write an indexer to get the data into VuFind's index (necessary!)
  • write a “Record Driver” to display that data appropriately within the VuFind interface (optional, if the index-based display meets your needs)

Indexer

Indexing is not an integrated part of VuFind. For indexing MARC records, solrmarc is distributed with VuFind. For other record formats, one needs different custom indexers. Some general hints on how to create such an indexer are given here.

Writing a custom indexer for other record formats may be done in almost any programming language. Steps to be done:

  • parse record format
  • map format entities to Solr index fields (see solr/biblio/conf/schema.xml for VuFind's index schema; the MARC mappings in import/marc.properties should be helpful for understanding the meaning of the various fields)
  • create XMLish document out of these fields (see the Solr Wiki for details)
  • POST document to Solr's update handler (FYI: it doesn't have to be a POST per se; you can use SOLR/Lucene APIs to add documents directly to the index which is much faster)

Note that for any metadata format available as XML, you can save yourself some steps by using the XSLT tool provided with recent versions of VuFind.

Record Display

Record display is handled by a family of “Record Driver” classes that extract information from the stored Solr fields and return it through a standard interface. The top-level parent Record Driver (found in web/RecordDrivers/IndexRecord.php) relies entirely on the Solr index fields, but children of this class (for example, web/RecordDrivers/MarcRecord.php) override and expand methods by using record-specific data extracted from the “fullrecord” field. Whenever record information is needed by VuFind, a Record Driver is instantiated through the Record Driver Factory (web/RecordDrivers/Factory.php) – the exact driver built is based on the “recordtype” field from Solr, and the default index-based Record Driver is used if no type-specific driver exists.

Driver API Specification

The interface that must be implemented by all Record Driver classes can be viewed in the SVN repository.

Record Driver naming conventions:

  • Filename: web/RecordDrivers/[record type]Record.php (i.e. web/RecordDrivers/MarcRecord.php)
  • Class name: same as the filename – [record type]Record (i.e. MarcRecord, IndexRecord, etc.)

Notes

  • The public Record Driver interface is intentionally very abstract – we want to be able to support records of all kinds, and we don't want to make any assumptions about the structure of the records.
  • In spite of the generic interface, it is often useful to have very structured methods (getTitle, getAuthor, etc.). These are implemented as protected methods in the default index-based Record Driver. They are useful within the driver itself, but should never be accessed from the outside – the interface between the record and the presentation layer must remain abstract to ensure future flexibility. However, there is nothing wrong with taking advantage of structure within the record driver hierarchy to make implementation of similar record formats easier.
  • To summarize the previous two points: if your data format represents bibliographic data in a way roughly similar to MARC, you can probably extend the IndexRecord class and override a few methods to do what you need. If your data format is wildly different, you probably want to build a whole new class based on the generic interface, and you shouldn't worry about the internals of the IndexRecord class.
legacy/vufind_1.x_developer_manual/supporting_a_new_metadata_format.txt · Last modified: 2015/12/14 11:52 by demiankatz