'Create an index on the specified field names
An index on a field is a mapping between the values taken by the field
and the sorted list of the ids of the records whose field is equal to
this value
For each indexed field, an attribute of self is created, an instance
of the class Index (see above). Its name it the field name, with the
prefix _ to avoid name conflicts'

def create_index(self, *fields):

    reset = False
    for f in fields:
        if (not (f in self.fields)):
            raise NameError(('%s    is    not    a    field    name    %s' % (f, self.fields)))
        if ((self.mode == 'open') and (f in self.indices)):
            continue
        reset = True
        self.indices[f] = {}
        for (_id, record) in self.records.items():
            bisect.insort(self.indices[f].setdefault(record[f], []), _id)
        setattr(self, ('_' + f), Index(self, f))
    if reset:
        self.commit()
