Hi Bernd,

On Thu, Jan 24, 2013 at 11:55 AM, Bernd Müller <belu...@googlemail.com> wrote:
> Hi Simon,
>
>> you mean where it is used? Look at the org.apache.lucene.codecs.Codec
>> class, it has a method:
>>
>>   public abstract StoredFieldsFormat storedFieldsFormat();
>>
>> which returns a stored fields format used to encode your stored fields
>> written by the index writer.
>
> Thanks for your quick reply. So I have to change the return value of
> the method storedFieldsFormat to a custom
> CompressingStoredFieldsFormat. Then, I set the codec in the
> IndexWriterConfig for the IndexWriter. If this is correct, my problem
> is solved.

This is correct. There are some explanations on how to register custom
codecs in the o.a.l.codecs package documentation:
http://lucene.apache.org/core/4_1_0/core/org/apache/lucene/codecs/package-summary.html#package_description.

Something you may need to consider if you are willing to read this
index with future versions of Lucene is that
CompressingStoredFieldsFormat is still experimental, so we might break
it in a non backward-compatible way in a future release. (But it is
possible to work around this problem: for example if we break it in
Lucene 4.2, all you need to do is to convert your index to the
Lucene41 codec using Lucene 4.1 and then re-converting your index back
to your custom codec using Lucene 4.2.)

> Next question that comes up: If I have different IndexWriters writing
> in the same index with different codecs, is the codec for the fields
> somehow resolved for an IndexReader? Or does every instance of an
> IndexWriter change the stored fields to its codec when committing and
> closing the index?

You should never have two IndexWriters writing to the same directory
at the same time. However there is no problem writing some segments
with a codec and then other segments with another codec. Your
DirectoryReader will just be composed of atomic readers which use
different codecs, which is fine, even for merging.

-- 
Adrien

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to