fr.gouv.culture.sdx.utils.lucene
Class LuceneDataStore

java.lang.Object
  extended byfr.gouv.culture.sdx.utils.SdxObjectImpl
      extended byfr.gouv.culture.sdx.utils.lucene.LuceneDataStore
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, SdxObject
Direct Known Subclasses:
LuceneDatabase, LuceneIndex

public abstract class LuceneDataStore
extends SdxObjectImpl

Created by IntelliJ IDEA. User: rpandey Date: Dec 10, 2002 Time: 1:56:41 PM To change this template use Options | File Templates.


Field Summary
static java.lang.String ALL_FIELD
          The field used to search for all documents.
static java.lang.String ALL_VALUE
          Value for the all field
protected  org.apache.lucene.analysis.Analyzer analyzer
          The analyzer for the index behind the datastore
protected  org.apache.lucene.store.FSDirectory fsd
          The Lucene filesystem directory where the index is stored.
protected  java.io.File fsdFile
          The location of the FSDirectory
static java.lang.String ID_FIELD
          The field name used to store the entity's id.
protected static java.lang.String LUCENE_CHECK_FILE
          The Lucene file to check to see if a database already exists.
protected  org.apache.lucene.search.Searcher searcher
          The Lucene searcher used for locating entities within the datastore.
static java.lang.String XML_LANG_FIELD
          A field name used to store a xml lang value if desired
 
Fields inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
encoding, logger
 
Constructor Summary
  LuceneDataStore()
           
protected LuceneDataStore(java.io.File dir)
           
 
Method Summary
protected  void delete(java.lang.String docId)
          Deletes a document from the index based upon its id field, marked protected as it is specfic implementation
protected  void delete(java.lang.String[] docIds)
          Deletes documents from the index based upon their id field, marked protected as it is specfic implementation
 void delete(org.apache.lucene.index.Term term)
          Deletes a document from the index based upon a term field
 void delete(org.apache.lucene.index.Term[] terms)
          List of terms to delete using a single index reader
protected  void finalize()
          Ensures that resources are freed
protected  void freeResources()
          Free's the resources associated with this data store USE WITH CARE!
protected  void getFSDirectory(boolean create)
          Set's the class field 'fsd' a FSDirectory instance for the fsdFile object
 java.lang.String getIndexPath()
          Return's the absolute path for the directory in which the database resides
protected  org.apache.lucene.index.IndexReader getReader()
          Returns an index reader for the current FSDirectory.
protected  org.apache.lucene.search.Searchable getSearcher()
          Gets the search class variable
protected  org.apache.lucene.index.IndexWriter getWriter()
          Gets an IndexWriter for the current FSDirectory
protected  org.apache.lucene.index.IndexWriter getWriter(org.apache.lucene.store.Directory directory)
          Get's an IndexWriter based upon the analyzer class field and the provided Lucene Directory
protected  void init(boolean create)
          Initializes the LuceneDataStore
protected  void optimize()
          Optimizeds the index for the current FSDirectory.
protected  void recycleSearcher()
          Recycles the searcher
 org.apache.lucene.search.Hits search(org.apache.lucene.search.Query q)
          Searches the database.
 org.apache.lucene.search.Hits search(org.apache.lucene.search.Query q, org.apache.lucene.search.Filter f)
          Searches the database.
 long size()
          Returns the number of entities within this database.
protected  void verifyIndex()
          Ensures we have an index to work with
protected  void write(org.apache.lucene.document.Document lDoc)
          Writes a document to the index
protected  void writeLuceneData(LuceneData ld)
           
 
Methods inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl
enableLogging, getChildLogger, setEncoding
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_FIELD

public static final java.lang.String ID_FIELD
The field name used to store the entity's id.

See Also:
Constant Field Values

ALL_FIELD

public static final java.lang.String ALL_FIELD
The field used to search for all documents.

See Also:
Constant Field Values

ALL_VALUE

public static final java.lang.String ALL_VALUE
Value for the all field

See Also:
Constant Field Values

XML_LANG_FIELD

public static final java.lang.String XML_LANG_FIELD
A field name used to store a xml lang value if desired

See Also:
Constant Field Values

LUCENE_CHECK_FILE

protected static final java.lang.String LUCENE_CHECK_FILE
The Lucene file to check to see if a database already exists.

See Also:
Constant Field Values

fsdFile

protected java.io.File fsdFile
The location of the FSDirectory


fsd

protected org.apache.lucene.store.FSDirectory fsd
The Lucene filesystem directory where the index is stored.


searcher

protected org.apache.lucene.search.Searcher searcher
The Lucene searcher used for locating entities within the datastore.


analyzer

protected org.apache.lucene.analysis.Analyzer analyzer
The analyzer for the index behind the datastore

Constructor Detail

LuceneDataStore

public LuceneDataStore()

LuceneDataStore

protected LuceneDataStore(java.io.File dir)
Method Detail

getIndexPath

public java.lang.String getIndexPath()
Return's the absolute path for the directory in which the database resides


init

protected void init(boolean create)
             throws SDXException
Initializes the LuceneDataStore

Throws:
SDXException

getFSDirectory

protected void getFSDirectory(boolean create)
                       throws SDXException
Set's the class field 'fsd' a FSDirectory instance for the fsdFile object

Throws:
SDXException

verifyIndex

protected void verifyIndex()
                    throws SDXException
Ensures we have an index to work with

Throws:
SDXException

recycleSearcher

protected void recycleSearcher()
                        throws SDXException
Recycles the searcher

Throws:
SDXException

getWriter

protected org.apache.lucene.index.IndexWriter getWriter()
                                                 throws java.io.IOException
Gets an IndexWriter for the current FSDirectory

Throws:
java.io.IOException

getWriter

protected org.apache.lucene.index.IndexWriter getWriter(org.apache.lucene.store.Directory directory)
                                                 throws java.io.IOException
Get's an IndexWriter based upon the analyzer class field and the provided Lucene Directory

Parameters:
directory - The lucene directory for which the writer is desired
Returns:
IndexWriter
Throws:
java.io.IOException

getReader

protected org.apache.lucene.index.IndexReader getReader()
                                                 throws SDXException
Returns an index reader for the current FSDirectory.

Throws:
SDXException

getSearcher

protected org.apache.lucene.search.Searchable getSearcher()
Gets the search class variable


optimize

protected void optimize()
                 throws SDXException
Optimizeds the index for the current FSDirectory.

Throws:
SDXException

write

protected void write(org.apache.lucene.document.Document lDoc)
              throws SDXException
Writes a document to the index

Parameters:
lDoc - The lucene document to add
Throws:
SDXException

writeLuceneData

protected void writeLuceneData(LuceneData ld)
                        throws SDXException
Throws:
SDXException

delete

protected void delete(java.lang.String docId)
               throws SDXException
Deletes a document from the index based upon its id field, marked protected as it is specfic implementation

Parameters:
docId - The id of the document to be deleted
Throws:
SDXException

delete

protected void delete(java.lang.String[] docIds)
               throws SDXException
Deletes documents from the index based upon their id field, marked protected as it is specfic implementation

Parameters:
docIds - The ids of the document to be deleted
Throws:
SDXException

delete

public void delete(org.apache.lucene.index.Term term)
            throws SDXException
Deletes a document from the index based upon a term field

Parameters:
term - The term of the document to be deleted
Throws:
SDXException

delete

public void delete(org.apache.lucene.index.Term[] terms)
            throws SDXException
List of terms to delete using a single index reader

Parameters:
terms -
Throws:
SDXException

freeResources

protected void freeResources()
                      throws java.io.IOException
Free's the resources associated with this data store USE WITH CARE!

Throws:
java.io.IOException - Lucene IOExceptions

finalize

protected void finalize()
                 throws java.lang.Throwable
Ensures that resources are freed

Throws:
java.lang.Throwable

search

public org.apache.lucene.search.Hits search(org.apache.lucene.search.Query q)
                                     throws SDXException
Searches the database.

Parameters:
q - A Lucene query.
Throws:
SDXException

search

public org.apache.lucene.search.Hits search(org.apache.lucene.search.Query q,
                                            org.apache.lucene.search.Filter f)
                                     throws SDXException
Searches the database.

Parameters:
q - A Lucene query.
Throws:
SDXException

size

public long size()
Returns the number of entities within this database.



Copyright © 2000-2004 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.