net.ontopia.infoset.fulltext.impl.lucene
Class LuceneIndexer

java.lang.Object
  extended by net.ontopia.infoset.fulltext.impl.lucene.LuceneIndexer
All Implemented Interfaces:
IndexerIF

public class LuceneIndexer
extends java.lang.Object
implements IndexerIF

INTERNAL: The Lucene indexer implementation. This indexer uses the Lucene search engine to index documents.


Field Summary
protected  org.apache.lucene.analysis.Analyzer analyzer
           
protected  org.apache.lucene.store.Directory dir
           
protected  java.lang.String path
           
protected  org.apache.lucene.index.IndexReader reader
           
protected  org.apache.lucene.index.IndexWriter writer
           
 
Constructor Summary
LuceneIndexer(org.apache.lucene.store.Directory dir, org.apache.lucene.analysis.Analyzer analyzer, boolean create)
          INTERNAL: Creates an indexer instance that will store its index in the given lucene directory and use the specified token stream analyzer.
LuceneIndexer(org.apache.lucene.store.Directory dir, boolean create)
          INTERNAL: Creates an indexer instance that will store its index in the given lucene directory and use the default token stream analyzer.
LuceneIndexer(java.lang.String path, org.apache.lucene.analysis.Analyzer analyzer, boolean create)
          INTERNAL: Creates an indexer instance that will store its index in the given file system directory and use the specified token stream analyzer.
LuceneIndexer(java.lang.String path, boolean create)
          INTERNAL: Creates an indexer instance that will store its index in the given file system directory.
 
Method Summary
 void close()
          INTERNAL: Closes the indexer.
 void delete()
          INTERNAL: Deletes the index.
 int delete(java.lang.String field, java.lang.String value)
          INTERNAL: Removes all documents with the specified field value from the index.
 void flush()
          INTERNAL: Flushes all changes done to the index.
 int getDocs()
          INTERNAL: Returns the number of documents stored in the index.
protected  org.apache.lucene.document.Document getDocument(DocumentIF document)
           
protected  org.apache.lucene.document.Field getField(FieldIF field)
           
protected  org.apache.lucene.document.Field.Index getIndexSetting(FieldIF field)
           
 java.lang.String getPath()
          INTERNAL: Returns the path where the index used is stored.
protected  org.apache.lucene.index.IndexReader getReader()
           
protected  org.apache.lucene.document.Field.Store getStoreSetting(FieldIF field)
           
protected  java.lang.String getStringValue(java.io.Reader reader)
           
protected  org.apache.lucene.index.IndexWriter getWriter()
           
 void index(DocumentIF document)
          INTERNAL: Indexes the specified document.
static void main(java.lang.String[] argv)
          INTERNAL: Command line version of the indexer.
protected static void usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

path

protected java.lang.String path

dir

protected org.apache.lucene.store.Directory dir

analyzer

protected org.apache.lucene.analysis.Analyzer analyzer

writer

protected org.apache.lucene.index.IndexWriter writer

reader

protected org.apache.lucene.index.IndexReader reader
Constructor Detail

LuceneIndexer

public LuceneIndexer(java.lang.String path,
                     boolean create)
              throws java.io.IOException
INTERNAL: Creates an indexer instance that will store its index in the given file system directory. Tokenization will be done using the StandardAnalyzer.

Parameters:
path - The file system directory where the index is located.
create - If true the indexer will create a new index (replacing the old one, if there is one). If false the indexed information will be added to the existing index.
Throws:
java.io.IOException

LuceneIndexer

public LuceneIndexer(java.lang.String path,
                     org.apache.lucene.analysis.Analyzer analyzer,
                     boolean create)
              throws java.io.IOException
INTERNAL: Creates an indexer instance that will store its index in the given file system directory and use the specified token stream analyzer.

Parameters:
path - The file system directory where the index is located.
analyzer - The token stream analyzer that the searcer is to use.
create - If true the indexer will create a new index (replacing the old one, if there is one). If false the indexed information will be added to the existing index.
Throws:
java.io.IOException

LuceneIndexer

public LuceneIndexer(org.apache.lucene.store.Directory dir,
                     boolean create)
              throws java.io.IOException
INTERNAL: Creates an indexer instance that will store its index in the given lucene directory and use the default token stream analyzer.

Parameters:
dir - The lucene directory where the index is located.
create - If true the indexer will create a new index (replacing the old one, if there is one). If false the indexed information will be added to the existing index.
Throws:
java.io.IOException
Since:
3.0

LuceneIndexer

public LuceneIndexer(org.apache.lucene.store.Directory dir,
                     org.apache.lucene.analysis.Analyzer analyzer,
                     boolean create)
              throws java.io.IOException
INTERNAL: Creates an indexer instance that will store its index in the given lucene directory and use the specified token stream analyzer.

Parameters:
dir - The lucene directory where the index is located.
analyzer - The token stream analyzer that the searcer is to use.
create - If true the indexer will create a new index (replacing the old one, if there is one). If false the indexed information will be added to the existing index.
Throws:
java.io.IOException
Method Detail

getWriter

protected org.apache.lucene.index.IndexWriter getWriter()

getReader

protected org.apache.lucene.index.IndexReader getReader()

getPath

public java.lang.String getPath()
INTERNAL: Returns the path where the index used is stored.


getDocs

public int getDocs()
INTERNAL: Returns the number of documents stored in the index.


index

public void index(DocumentIF document)
           throws java.io.IOException
Description copied from interface: IndexerIF
INTERNAL: Indexes the specified document. This includes tokenizing, indexing and storing the document fields.

Specified by:
index in interface IndexerIF
Throws:
java.io.IOException

delete

public int delete(java.lang.String field,
                  java.lang.String value)
           throws java.io.IOException
Description copied from interface: IndexerIF
INTERNAL: Removes all documents with the specified field value from the index. This method should generally be, but is not limited to, used to delete documents by their identity field.

Specified by:
delete in interface IndexerIF
Returns:
The number of documents that was deleted from the index. -1 is return if this number is unknown.
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from interface: IndexerIF
INTERNAL: Flushes all changes done to the index. A flushing operation can include actions like persisting changes and optimizing the index.

Specified by:
flush in interface IndexerIF
Throws:
java.io.IOException

delete

public void delete()
            throws java.io.IOException
Description copied from interface: IndexerIF
INTERNAL: Deletes the index. The indexer is closed after this method returns. Note that some indexers might not support this operation.

Specified by:
delete in interface IndexerIF
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from interface: IndexerIF
INTERNAL: Closes the indexer. After the indexer has been closed it cannot (generally) be reopened.

Specified by:
close in interface IndexerIF
Throws:
java.io.IOException

getDocument

protected org.apache.lucene.document.Document getDocument(DocumentIF document)
                                                   throws java.io.IOException
Throws:
java.io.IOException

getField

protected org.apache.lucene.document.Field getField(FieldIF field)
                                             throws java.io.IOException
Throws:
java.io.IOException

getStoreSetting

protected org.apache.lucene.document.Field.Store getStoreSetting(FieldIF field)

getIndexSetting

protected org.apache.lucene.document.Field.Index getIndexSetting(FieldIF field)

getStringValue

protected java.lang.String getStringValue(java.io.Reader reader)
                                   throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] argv)
INTERNAL: Command line version of the indexer.


usage

protected static void usage()


Copyright © 2000-2012 Ontopia.