FileDocCategorySizeDatePackage
GDataIndexWriter.javaAPI DocApache Lucene 2.1.03967Wed Feb 14 10:46:06 GMT 2007org.apache.lucene.gdata.search.index

GDataIndexWriter

public class GDataIndexWriter extends IndexWriter
Configurable decorator for a lucene {@link IndexWriter}
author
Simon Willnauer

Fields Summary
private static final Log
LOG
private String
serviceName
Constructors Summary
protected GDataIndexWriter(Directory arg0, boolean arg1, org.apache.lucene.gdata.search.config.IndexSchema arg2)
Creates and configures a new GdataIndexWriter

param
arg0 - the index directory
param
arg1 - create index
param
arg2 - the index schema configuration including all parameter to set up the index writer
throws
IOException -if the directory cannot be read/written to, or if it does not exist, and create is false

        /*
         * Use Schema Analyzer rather than service analyzer. 
         * Schema analyzer returns either the service analyzer or a per field analyzer if configured.
         */
        super(arg0, (arg2 == null ? new StandardAnalyzer() : arg2.getSchemaAnalyzer()), arg1);
        if (arg2 == null) {
            /*
             * if no schema throw exception - schema is mandatory for the index writer.
             */
            try {
                this.close();
            } catch (IOException e) {
                //
            }
            throw new IllegalArgumentException("configuration must not be null");

        }
        this.initialize(arg2);
    
Methods Summary
public voidclose()

see
org.apache.lucene.index.IndexWriter#close()

        super.close();
        LOG.info("Closing GdataIndexWriter for service " + this.serviceName);
    
private voidinitialize(org.apache.lucene.gdata.search.config.IndexSchema config)


        
        this.serviceName = config.getName();
        setUseCompoundFile(config.isUseCompoundFile());
        if (config.getMaxBufferedDocs() != IndexSchema.NOT_SET_VALUE)
            setMaxBufferedDocs(config.getMaxBufferedDocs());
        if (config.getMaxMergeDocs() != IndexSchema.NOT_SET_VALUE)
            setMaxMergeDocs(config.getMaxMergeDocs());
        if (config.getMergeFactor() != IndexSchema.NOT_SET_VALUE)
            setMergeFactor(config.getMergeFactor());
        if (config.getMaxFieldLength() != IndexSchema.NOT_SET_VALUE)
            setMaxFieldLength(config.getMaxFieldLength());
        if (config.getWriteLockTimeout() != IndexSchema.NOT_SET_VALUE)
            setWriteLockTimeout(config.getWriteLockTimeout());
        //no commit lock anymore
        //TODO fix this
//        if (config.getCommitLockTimeout() != IndexSchema.NOT_SET_VALUE)
//            setCommitLockTimeout(config.getCommitLockTimeout());