lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <>
Subject Re: [lucy-user] Merging without defining schema, fields, et al
Date Thu, 15 Sep 2011 12:38:46 GMT
On Thu, Sep 15, 2011 at 01:49:39PM +0200, goran kent wrote:
> Reaching here, but I don't suppose there's a util or way of merging
> indexes without having to go through the rigmarole of creating a
> Lucy::Plan::Schema object, defining all the fields, etc, etc?

The "schema" parameter to Indexer's constructor is only required when
initializing an index.  When the index gets written out, the Schema object
will be serialized so that it can be accessed later.  (Implementation detail:
it will go into the file index_dir/schema_NNN.json, where NNN is a
"generation" number).

On subsequent indexing sessions, when the index already exists, Indexer's
constructor deserializes a Schema from the JSON file and uses that.  If you
also supply a value for "schema" to Indexer's constructor at that time,
Indexer will check to make sure that it is compatible with the existing

If you need to extract a Schema from an existing index, perhaps because you
have created all your child indexes before you have created the master, here's
one way:

  my $reader = Lucy::Index::IndexReader->open(index => '/path/to/child');
  my $schema = $reader->get_schema,
  my $indexer = Lucy::Index::Indexer->new(
    index  => '/path/to/master',
    schema => $schema,
    create => 1,


Marvin Humphrey

View raw message