Cheshire3 Objects: Database

|  | # Cheshire3 Objects: Database

## Description

A Database is a collection of Records and Indexes. It is responsable for maintaining and allowing access to its components, as well as metadata associated with the collections. It must be able to interpret a request, splitting it amongst its known resources and then recombine the values into a single response.

## Implementations

There are no pre-configured databases as this is totally application specific. Configuring a database it your primary task when beginning to use Cheshire3 for your data. There are some example databases including confiuguration available in the download section of the Cheshire3 web-site.

## API

Module: cheshire3.database
Classes:

- SimpleDatabase
  A simple database implementation. Handles the basics, but not authentication.
- OptimisingDatabase
  Slightly experimental query optimising database. Attempts to canonicalize the query, and discern whether there will be any matches before actually creating resultSets (creating resultSets is what takes the time when searching!)

Database Methods:

Function | Parameters | Returns | Description
--- | --- | --- | ---
__init__ | domNode, parentObject |  | The constructer takes a DOM tree containing the configuration of the database and the object which the database should consider as its parent, normally a Server.
begin_indexing | session |  | Perform any routines required before indexing records. e.g. discover configured indexes, initialize necessary files.
commit_indexing | session |  | Perform any routines needed to complete indexing. e.g. collate temporary index files, commit finished indexes to disk.
commit_metadata | session |  | Perform any routines needed to complete accumulation of metadata. e.g. calculate mean record size, commit values to disk.
clear_indexes | session |  | Discover all configured indexes and clear them. This can prevent duplicates if called before re-indexing existing Records.
add_record | session, record |  | Function to call to ensure that a record is registered with the database. This will only do the registration, you have to call index_record to index it.
index_record | session, record |  | Sends the record to all known indexes to process
unindex_record | session, record |  | Remove references to the record from all known indexes. Does not delete the record from the recordStore.
remove_record | session, record |  | Remove the record from the database's register. This will only unregister the record, you have to call unindex_record to remove pointers from indexes.
scan | session, query, numberOfTerms, direction | list of term summaries | Given a query, resolve the index and return the raw information from it. Each item in the list returned consists of the term it represents (as a string), followed by a sequence of 3 integers: term id, number of matching records, total number of occurences.
search | session, query | resultSet | Given a query, process it and return a resultSet

### Sub-Packages

Sub-Package: vdb
Module: cheshire3.vdb.database

- VdbDatabase
  A Virtual Database implementation for federated/meta searching remote databases. Currently supports SRU enabled remote databases only. Accurate relevancy sorting relies on remote database supporting SRU extension: cheshire3-2-resultSet. Search facets rely on remote database supporting SRU extension: cheshire3-2-facets.