org.carrot2.source.lucene
Class LuceneDocumentSource

java.lang.Object
  extended by org.carrot2.core.ProcessingComponentBase
      extended by org.carrot2.source.lucene.LuceneDocumentSource
All Implemented Interfaces:
IDocumentSource, IProcessingComponent

public final class LuceneDocumentSource
extends ProcessingComponentBase
implements IDocumentSource

A IDocumentSource fetching Documents from a local Apache Lucene index. The index should be binary-compatible with the Lucene version actually imported by this plugin.


Field Summary
 org.apache.lucene.analysis.Analyzer analyzer
          Analyzer used at indexing time.
 org.apache.lucene.store.Directory directory
          Search index Directory.
 Collection<Document> documents
           
 IFieldMapper fieldMapper
          IFieldMapper provides the link between Carrot2 Document fields and Lucene index fields.
 boolean keepLuceneDocuments
          Keeps references to Lucene document instances in Carrot2 documents.
static String LUCENE_DOCUMENT_FIELD
          Carrot2 Document field that stores the original Lucene document instance.
 Object query
          A pre-parsed Query object or a String parsed using the built-in QueryParser over a set of search fields returned from the fieldMapper.
 int results
           
 long resultsTotal
           
 
Constructor Summary
LuceneDocumentSource()
           
 
Method Summary
protected  SearchEngineResponse fetchSearchResponse()
          Fetch search engine response.
 void init(IControllerContext context)
          Invoked after component's attributes marked with Init and Input annotations have been bound, but before calls to any other methods of this component.
 void process()
          Performs the processing required to fulfill the request.
 
Methods inherited from class org.carrot2.core.ProcessingComponentBase
afterProcessing, beforeProcessing, dispose, getContext, getSharedExecutor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.carrot2.core.IProcessingComponent
afterProcessing, beforeProcessing, dispose
 

Field Detail

results

public int results

resultsTotal

public long resultsTotal

documents

public Collection<Document> documents

directory

public org.apache.lucene.store.Directory directory
Search index Directory. Must be unlocked for reading.

Attribute label:
Index directory
Attribute level:
Basic
Attribute group:
Index properties

analyzer

public org.apache.lucene.analysis.Analyzer analyzer
Analyzer used at indexing time. The same analyzer should be used for querying.

Attribute label:
Analyzer
Attribute level:
Medium
Attribute group:
Index properties

fieldMapper

public IFieldMapper fieldMapper
IFieldMapper provides the link between Carrot2 Document fields and Lucene index fields.

Attribute label:
Field mapper
Attribute level:
Advanced
Attribute group:
Index field mapping

query

public Object query
A pre-parsed Query object or a String parsed using the built-in QueryParser over a set of search fields returned from the fieldMapper.

Attribute label:
Query
Attribute level:
Basic
Attribute group:
Search query

keepLuceneDocuments

public boolean keepLuceneDocuments
Keeps references to Lucene document instances in Carrot2 documents. Please bear in mind two limitations:

Attribute label:
Keep Lucene documents
Attribute level:
Advanced
Attribute group:
Results

LUCENE_DOCUMENT_FIELD

public static final String LUCENE_DOCUMENT_FIELD
Carrot2 Document field that stores the original Lucene document instance. Keeping of Lucene document instances is disabled by default. Enable it using the keepLuceneDocuments attribute.

See Also:
Constant Field Values
Constructor Detail

LuceneDocumentSource

public LuceneDocumentSource()
Method Detail

init

public void init(IControllerContext context)
Description copied from interface: IProcessingComponent
Invoked after component's attributes marked with Init and Input annotations have been bound, but before calls to any other methods of this component. After a call to this method completes without an exception, attributes marked with Init Output will be collected. In this method, components should perform initializations based on the initialization-time attributes. This method is called once in the life time of a processing component instance.

Specified by:
init in interface IProcessingComponent
Overrides:
init in class ProcessingComponentBase
Parameters:
context - An instance of IControllerContext of the controller to which this component instance will be bound.

process

public void process()
             throws ProcessingException
Description copied from interface: IProcessingComponent
Performs the processing required to fulfill the request. This method is called once per request.

Specified by:
process in interface IProcessingComponent
Overrides:
process in class ProcessingComponentBase
Throws:
ProcessingException - when processing failed. If thrown, the IProcessingComponent.afterProcessing() method will be called and the component will be ready to accept further requests or to be disposed of. Finally, the exception will be rethrown from the controller method that caused the component to perform processing.

fetchSearchResponse

protected SearchEngineResponse fetchSearchResponse()
                                            throws Exception
Fetch search engine response.

Throws:
Exception


Copyright (c) Dawid Weiss, Stanislaw Osinski