net.conquiris.api.index
Interface Writer

All Superinterfaces:
DocumentWriter

public interface Writer
extends DocumentWriter

Conquiris index writer interface. Commit properties starting with the 'cq:' prefix are reserved. If no state modifiers methods are called nothing will be commited to the index. Implementations MUST BE thread-safe. All methods throw IllegalStateException if the writer can no longer be used, InterruptedException if the thread they are running is interrupted and IndexException if there's a problem with the index.

Author:
Andres Rodriguez

Method Summary
 Writer add(org.apache.lucene.document.Document document)
          Adds a document.
 Writer add(org.apache.lucene.document.Document document, org.apache.lucene.analysis.Analyzer analyzer)
          Adds a document.
 void cancel()
          Cancels the operation of this writer.
 Writer delete(String field, String text)
          Deletes documents matching a certain term.
 Writer delete(org.apache.lucene.index.Term term)
          Deletes documents matching a certain term.
 Writer deleteAll()
          Deletes all documents.
 String getCheckpoint()
          Returns the commit checkpoint, or null if there was no checkpoint.
 IndexInfo getIndexInfo()
          Returns the last commit index info.
 String getProperty(String key)
          Returns a commit property.
 Set<String> getPropertyKeys()
          Returns the existing property keys.
 String getTargetCheckpoint()
          Returns the last known target checkpoint, or null if there was no checkpoint.
 Writer runSubindexers(Executor executor, Iterable<? extends Subindexer> subindexers)
          Runs a collection of subindexers using the provided executor, waiting for them to finish.
 Writer setCheckpoint(String checkpoint)
          Sets the new checkpoint.
 Writer setProperties(Map<String,String> values)
          Sets a collection of commit property value.
 Writer setProperty(String key, String value)
          Sets a commit property value.
 Writer setTargetCheckpoint(String targetCheckpoint)
          Sets the new target checkpoint.
 Writer update(String field, String text, org.apache.lucene.document.Document document)
          Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.
 Writer update(String field, String text, org.apache.lucene.document.Document document, org.apache.lucene.analysis.Analyzer analyzer)
          Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.
 Writer update(org.apache.lucene.index.Term term, org.apache.lucene.document.Document document)
          Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.
 Writer update(org.apache.lucene.index.Term term, org.apache.lucene.document.Document document, org.apache.lucene.analysis.Analyzer analyzer)
          Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.
 

Method Detail

cancel

void cancel()
            throws InterruptedException
Cancels the operation of this writer. Indexer can continue but all operations will be ignored and the index writer will be rolled back.

Throws:
InterruptedException

getIndexInfo

IndexInfo getIndexInfo()
                       throws InterruptedException
Returns the last commit index info.

Throws:
InterruptedException

getCheckpoint

String getCheckpoint()
                     throws InterruptedException
Returns the commit checkpoint, or null if there was no checkpoint. Includes the modifications performed in this writer.

Throws:
InterruptedException

getTargetCheckpoint

String getTargetCheckpoint()
                           throws InterruptedException
Returns the last known target checkpoint, or null if there was no checkpoint. Includes the modifications performed in this writer.

Throws:
InterruptedException

getProperty

String getProperty(String key)
                   throws InterruptedException
Returns a commit property. Includes the modifications performed in this writer.

Parameters:
key - Property key.
Returns:
The property value or null if the property does no exist.
Throws:
IllegalArgumentException - if a reserved property is requested.
InterruptedException

getPropertyKeys

Set<String> getPropertyKeys()
                            throws InterruptedException
Returns the existing property keys. Includes the modifications performed in this writer.

Returns:
The (unmodifiable) set of existing property keys.
Throws:
InterruptedException

setCheckpoint

Writer setCheckpoint(@Nullable
                     String checkpoint)
                     throws InterruptedException
Sets the new checkpoint. It will only be considered a modifying operation if the checkpoint is different.

Parameters:
checkpoint - New checkpoint.
Returns:
This writer for method chaining.
Throws:
InterruptedException

setTargetCheckpoint

Writer setTargetCheckpoint(@Nullable
                           String targetCheckpoint)
                           throws InterruptedException
Sets the new target checkpoint. It will only be considered a modifying operation if the checkpoint is different.

Parameters:
targetCheckpoint - New target checkpoint.
Returns:
This writer for method chaining.
Throws:
InterruptedException

setProperty

Writer setProperty(String key,
                   String value)
                   throws InterruptedException
Sets a commit property value.

Parameters:
key - Property key.
value - Value to set. If null the property is removed.
Returns:
This writer for method chaining.
Throws:
IllegalArgumentException - if a provided key is reserverd.
InterruptedException

setProperties

Writer setProperties(Map<String,String> values)
                     throws InterruptedException
Sets a collection of commit property value.

Parameters:
values - Values to set. For those properties which value is null the property will be removed.
Returns:
This writer for method chaining.
Throws:
IllegalArgumentException - if any of the provided key is reserved.
InterruptedException

add

Writer add(@Nullable
           org.apache.lucene.document.Document document)
           throws InterruptedException,
                  IndexException
Adds a document. The service default analyzer will be used.

Specified by:
add in interface DocumentWriter
Parameters:
document - Document to add. If null the method is a no-op.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

add

Writer add(@Nullable
           org.apache.lucene.document.Document document,
           @Nullable
           org.apache.lucene.analysis.Analyzer analyzer)
           throws InterruptedException,
                  IndexException
Adds a document.

Specified by:
add in interface DocumentWriter
Parameters:
document - Document to add. If null the method is a no-op.
analyzer - Analyzer to use. If null the service default analyzer will be used.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

deleteAll

Writer deleteAll()
                 throws InterruptedException,
                        IndexException
Deletes all documents.

Specified by:
deleteAll in interface DocumentWriter
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

delete

Writer delete(@Nullable
              String field,
              @Nullable
              String text)
              throws InterruptedException,
                     IndexException
Deletes documents matching a certain term.

Specified by:
delete in interface DocumentWriter
Parameters:
field - Field to match. If null the method is a no-op.
text - Term text to match. If null the method is a no-op.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

delete

Writer delete(@Nullable
              org.apache.lucene.index.Term term)
              throws InterruptedException,
                     IndexException
Deletes documents matching a certain term.

Specified by:
delete in interface DocumentWriter
Parameters:
term - Term to match. If null the method is a no-op.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

update

Writer update(@Nullable
              String field,
              @Nullable
              String text,
              @Nullable
              org.apache.lucene.document.Document document)
              throws InterruptedException,
                     IndexException
Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.

Specified by:
update in interface DocumentWriter
Parameters:
field - Field to match. If null no deletion will be performed.
text - Term text to match. If null no deletion will be performed.
document - Document to add. If null no document will be added.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

update

Writer update(@Nullable
              org.apache.lucene.index.Term term,
              @Nullable
              org.apache.lucene.document.Document document)
              throws InterruptedException,
                     IndexException
Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.

Specified by:
update in interface DocumentWriter
Parameters:
term - Term to match. If null no deletion will be performed.
document - Document to add. If null no document will be added.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

update

Writer update(@Nullable
              String field,
              @Nullable
              String text,
              @Nullable
              org.apache.lucene.document.Document document,
              @Nullable
              org.apache.lucene.analysis.Analyzer analyzer)
              throws InterruptedException,
                     IndexException
Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.

Specified by:
update in interface DocumentWriter
Parameters:
field - Field to match. If null no deletion will be performed.
text - Term text to match. If null no deletion will be performed.
document - Document to add. If null no document will be added.
analyzer - Analyzer to use. If null the service default analyzer will be used.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

update

Writer update(@Nullable
              org.apache.lucene.index.Term term,
              @Nullable
              org.apache.lucene.document.Document document,
              @Nullable
              org.apache.lucene.analysis.Analyzer analyzer)
              throws InterruptedException,
                     IndexException
Atomically (with respect to index flushing) deletes the documents matching a certain term and adds a document.

Specified by:
update in interface DocumentWriter
Parameters:
term - Term to match. If null no deletion will be performed.
document - Document to add. If null no document will be added.
analyzer - Analyzer to use. If null the service default analyzer will be used.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException

runSubindexers

Writer runSubindexers(Executor executor,
                      Iterable<? extends Subindexer> subindexers)
                      throws InterruptedException,
                             IndexException
Runs a collection of subindexers using the provided executor, waiting for them to finish.

Parameters:
executor - Executor to use.
subindexers - Indexers to run.
Returns:
This writer for method chaining.
Throws:
InterruptedException
IndexException


Copyright © 2012 Derquinse Projects.. All Rights Reserved.