Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    java.lang.Object
      fr.gouv.culture.sdx.utils.AbstractSdxObject
          fr.gouv.culture.sdx.utils.lucene.LuceneDataStore

All Implemented Interfaces:
  org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, Describable, Encodable, Identifiable, Localizable, org.apache.avalon.framework.logger.LogEnabled, Saveable, SdxObject, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

Direct Known Subclasses:
  LuceneDatabase, LuceneIndex

public abstract class LuceneDataStore
extends AbstractSdxObject
implements Saveable

Nested Class Summary

Nested classes inherited from class fr.gouv.culture.sdx.utils.SdxObject
`SdxObject.ConfigurationNode`

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 org.apache.lucene.search.Searcher` | `searcher` The Lucene searcher used for locating entities within the datastore.
`protected boolean` | `useCompoundFiles` Specify if using the compound file format when indexing
`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.AbstractSdxObject
`_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized`

Fields inherited from interface fr.gouv.culture.sdx.utils.save.Saveable
`ALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM`

Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
`DEFAULT_ENCODING`

Constructor Summary
`` | `LuceneDataStore()`
`protected` | `LuceneDataStore(java.io.File dir)`

Method Summary
`void` | `backup(SaveParameters save_config)` Save Lucene files
`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)` Sets the class field 'fsd' a FSDirectory instance for the fsdFile object
`protected org.apache.lucene.store.FSDirectory` | `getFSDirectory(java.io.File dir, boolean create)`
`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(boolean create)`
`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 org.apache.lucene.index.IndexWriter` | `getWriter(org.apache.lucene.store.Directory directory, boolean create)`
`protected void` | `init(boolean create)` Initializes the LuceneDataStore
`protected boolean` | `initToSax()` Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML
`protected void` | `initVolatileObjectsToSax()` Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called
`boolean` | `isUsingCompoundFiles()` Say if Lucene uses the compound files
`protected void` | `optimize()` Optimizeds the index for the current FSDirectory.
`void` | `recycleSearcher()` Recycles the searcher
`void` | `restore(SaveParameters save_config)` Restore Lucene files
`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.
`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.AbstractSdxObject
`configure, configureDescription, contextualize, enableLogging, getBaseAttributes, getClassNameSuffix, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### useCompoundFiles

    protected boolean useCompoundFiles

  Specify if using the compound file format when indexing

### 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

### 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

### isUsingCompoundFiles

    public boolean isUsingCompoundFiles()

  Say if Lucene uses the compound files

  Returns:
    useCompoundFiles

### init

    protected void init(boolean create)
                 throws SDXException

  Initializes the LuceneDataStore

  Throws:
    `SDXException`

### getFSDirectory

    protected void getFSDirectory(boolean create)
                           throws SDXException

  Sets the class field 'fsd' a FSDirectory instance for the fsdFile object

  Throws:
    `SDXException`

### getFSDirectory

    protected org.apache.lucene.store.FSDirectory getFSDirectory(java.io.File dir,
                                                                 boolean create)
                                                          throws SDXException

  Throws:
    `SDXException`

### verifyIndex

    public void verifyIndex()
                     throws SDXException

  Ensures we have an index to work with

  Throws:
    `SDXException`

### recycleSearcher

    public 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(boolean create)
                                                     throws java.io.IOException

  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`

### getWriter

    protected org.apache.lucene.index.IndexWriter getWriter(org.apache.lucene.store.Directory directory,
                                                            boolean create)
                                                     throws java.io.IOException

  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.

### initToSax

    protected boolean initToSax()

  Description copied from class: `AbstractSdxObject`
  Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML

  Specified by:
    `initToSax` in class `AbstractSdxObject`

### initVolatileObjectsToSax

    protected void initVolatileObjectsToSax()

  Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called

  Specified by:
    `initVolatileObjectsToSax` in class `AbstractSdxObject`

### backup

    public void backup(SaveParameters save_config)
                throws SDXException

  Save Lucene files

  Specified by:
    `backup` in interface `Saveable`
  Throws:
    `SDXException`
  See Also:
    `Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)`

### restore

    public void restore(SaveParameters save_config)
                 throws SDXException

  Restore Lucene files

  Specified by:
    `restore` in interface `Saveable`
  Parameters:
    `save_config` -
  Throws:
    `SDXException`
  See Also:
    `Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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