@Bindable(prefix="LuceneDocumentSource",
inherit=CommonAttributes.class)
public final class LuceneDocumentSource
extends ProcessingComponentBase
implements IDocumentSource
IDocumentSource fetching Documents from a local Apache Lucene index.
The index should be binary-compatible with the Lucene version actually imported by this
plugin.| Modifier and Type | Field and Description |
|---|---|
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. |
protected static String |
INDEX_PROPERTIES |
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 classic QueryParser over a
set of search fields returned from the fieldMapper. |
int |
results |
long |
resultsTotal |
| Constructor and Description |
|---|
LuceneDocumentSource() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
afterProcessing, beforeProcessing, dispose, getContext, getSharedExecutorclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterProcessing, beforeProcessing, disposeprotected static final String INDEX_PROPERTIES
@Processing @Input @Attribute(key="results", inherit=true) @IntRange(min=1) public int results
@Processing @Output @Attribute(key="results-total", inherit=true) public long resultsTotal
@Processing @Output @Attribute(key="documents", inherit=true) @Internal public Collection<Document> documents
@Input @Attribute @Processing @Required @Internal(configuration=true) @Label(value="Index directory") @Level(value=BASIC) @Group(value="Index properties") public org.apache.lucene.store.Directory directory
Directory. Must be unlocked for
reading.@Input @Processing @Required @Attribute @Internal(configuration=false) @Label(value="Analyzer") @Level(value=MEDIUM) @Group(value="Index properties") public org.apache.lucene.analysis.Analyzer analyzer
Analyzer used at indexing time. The same
analyzer should be used for querying.@Input @Processing @Required @Attribute @Internal @Label(value="Field mapper") @Level(value=ADVANCED) @Group(value="Index field mapping") public IFieldMapper fieldMapper
IFieldMapper provides the link between Carrot2
Document fields and Lucene index fields.@Input @Processing @Attribute(key="query", inherit=false) @Required @Label(value="Query") @Level(value=BASIC) @Group(value="Search query") public Object query
Query object or a String
parsed using the built-in classic QueryParser over a
set of search fields returned from the fieldMapper.@Input @Processing @Attribute @Internal @Label(value="Keep Lucene documents") @Level(value=ADVANCED) @Group(value="Search result information") public boolean keepLuceneDocuments
IFieldMapper that will store those fields as regular
Carrot2 fields.Controller
configured to cache the
output from LuceneDocumentSource.public static final String LUCENE_DOCUMENT_FIELD
Document field that stores the original Lucene document instance.
Keeping of Lucene document instances is disabled by default. Enable it using the
keepLuceneDocuments attribute.public void init(IControllerContext context)
IProcessingComponentInit 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.init in interface IProcessingComponentinit in class ProcessingComponentBasecontext - An instance of IControllerContext of the controller to which this
component instance will be bound.public void process()
throws ProcessingException
IProcessingComponentprocess in interface IProcessingComponentprocess in class ProcessingComponentBaseProcessingException - 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.protected SearchEngineResponse fetchSearchResponse() throws Exception
Exception