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.search.lucene.query
Class LuceneIndex

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

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

    public class LuceneIndex

extends LuceneDataStore
implements SdxObject, Index

Information and services related to a LuceneIndex.

From here we can get an IndexReader, a Searcher, and know a little more about defined fields.

Nested Class Summary

Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject
`SdxObject.ConfigurationNode`

Field Summary
`static int` | `ACTION_ADD_DOCUMENT` int representation of indexing action for adding a document.
`protected java.util.Date` | `creationTimestamp` The creation date of this index
`java.lang.String` | `CURRENT_INDEX_DIR` The current directory name
`static int` | `DEFAULT_MAX_FIELD_LENGTH` Defaults for IndexWriter parameters; these are based on lucene defaults
`static int` | `DEFAULT_MAX_MERGE_DOCS` Defaults for IndexWriter parameters; these are based on lucene defaults
`static int` | `DEFAULT_MERGE_FACTOR` Defaults for IndexWriter parameters; these are based on lucene defaults
`protected java.io.File` | `lastModFile` The "last-modification-timestamp" file
`protected long` | `lastModificationTimestamp` The last modification timestamp of this index

Fields inherited from class fr.gouv.culture.sdx.utils.lucene.LuceneDataStore
`ALL_FIELD, ALL_VALUE, analyzer, fsd, fsdFile, ID_FIELD, searcher, useCompoundFiles, XML_LANG_FIELD`

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.Encodable
`DEFAULT_ENCODING`

Fields inherited from interface fr.gouv.culture.sdx.search.lucene.query.Index
`CLASS_NAME_SUFFIX, CREATION_TIMESTAMP_FILENAME, LAST_MODIFICATION_DATE_FILENAME`

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

Constructor Summary
`LuceneIndex(java.io.File dir, java.lang.String host, java.lang.Integer port, java.lang.String appId, java.lang.String dbId)` Builds an index with fields definition and a path to the index files.
`LuceneIndex(java.io.File dir, java.lang.String host, java.lang.Integer port, java.lang.String appId, java.lang.String dbId, boolean useCompoundFiles)`
`LuceneIndex(LuceneIndex parentIndex)` Sub index constructor
`LuceneIndex(LuceneIndex parentIndex, java.io.File dir)` Sub index constructor

Method Summary
`void` | `backup(SaveParameters save_config)` Save LuceneIndex files
`void` | `configure(org.apache.avalon.framework.configuration.Configuration configuration)`
`void` | `deleteDocument(java.lang.String docId)` Deletes a document from the index.
`int` | `docCount()`
`void` | `freeResources()` Free's the resources associated with this index USE WITH CARE!
`protected java.lang.String` | `getClassNameSuffix()` Sub classes should element this method to return their class name suffix for SAX output
`java.util.Date` | `getCreationDate()` Returns the creation date of this Lucene index.
`Field` | `getDefaultField()` Returns the default field for this index.
`Field` | `getField(java.lang.String name)` Returns a field given a name.
`int` | `getFieldType(java.lang.String name)` Returns the type of a field.
`java.lang.String` | `getFieldValue(IndexableDocument doc, java.lang.String fieldName)` Gets the value of a field.
`java.util.Date` | `getLastModificationDate()` Returns the last modification date Returns the the last modification timestamp of this Lucene index as a Date.
`long` | `getLastModificationTimestamp()` Returns the last modification timestamp
`java.util.Locale` | `getLocale(java.lang.String name)` Returns the locale for a field.
`MetaAnalyzer` | `getMetaAnalyzer()` Gets the MetaAnalyzer
`QueryParser` | `getQueryParser()`
`org.apache.lucene.index.IndexReader` | `getReader()` Gets a Lucene reader Ensures we have a correct Lucene reader for this index.
`org.apache.lucene.index.IndexReader` | `getReader(boolean automaticRecycle)`
`java.lang.String` | `getRemoteIndexName()`
`org.apache.lucene.search.Searchable` | `getSearcher()` Gets a Lucene searcher Ensures we have a correct Lucene searcher for this index.
`org.apache.lucene.search.Searchable` | `getSearcher(boolean automaticRecycle)`
`protected org.apache.lucene.index.IndexWriter` | `getWriter(org.apache.lucene.store.Directory directory)` Gets a writer for the Lucene index
`protected org.apache.lucene.index.IndexWriter` | `getWriter(org.apache.lucene.store.Directory directory, boolean create)`
`boolean` | `hasBeenModified()` Has Lucene index been modified Returns true if this Lucene index has been modified since the last modification timestamp.
`void` | `indexModified()`
`void` | `indexModified(boolean createLastModficationTimestampFile)` Deprecated. Use `indexModified()` instead.
`void` | `init()` Initializes the Lucene database.
`boolean` | `isSubIndex()` Tell if the index is a subIndex or not
`void` | `mergeCurrentBatch()` Merges any batch in memory
`void` | `mergeCurrentBatch(boolean optimize)` Merges any batch in memory and optimize it if necessary
`void` | `optimize()` Index file optimization
`void` | `recycleIndexReader()` Recycles the Lucene reader for this index
`void` | `recycleLuceneIndexSearcher()` Recycles the Lucene searcher for this index
`void` | `recycleSearcherReader()` Recycles Lucene Searcher and Reader
`void` | `restore(SaveParameters save_config)` Restore LuceneIndex files
`protected void` | `setDocCount(int i)`
`void` | `setMetaAnalyzer(MetaAnalyzer mAnalyzer)` Sets the MetaAnalyzer
`void` | `setParameters(LuceneIndexParameters params)` Sets the indexing parameters
`void` | `toSAX(org.xml.sax.ContentHandler hdl)`
`protected void` | `writeCreationTimestampFile()` Creates the file that represents the creation timestamp of this Lucene index if relevant
`void` | `writeDocument(org.apache.lucene.document.Document ldoc, boolean batchIndex)` Stores a Lucene document within the database.
`void` | `writeDocument(org.apache.lucene.document.Document ldoc, boolean batchIndex, boolean autoOptimize)` Stores a Lucene document within the database.
`void` | `writeLastModificationTimestampFile()` Updates the date of the last modification timestamp of this Lucene index Updates the date of the last modification timestamp of this Lucene index.
`void` | `writeLastModificationTimestampFile(boolean create)` Deprecated. Use `writeCreationTimestampFile()` instead.

Methods inherited from class fr.gouv.culture.sdx.utils.lucene.LuceneDataStore
`delete, delete, delete, delete, finalize, getFSDirectory, getFSDirectory, getIndexPath, getWriter, getWriter, init, initToSax, initVolatileObjectsToSax, isUsingCompoundFiles, recycleSearcher, search, search, size, verifyIndex, write, writeLuceneData`

Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
`configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, verifyConfigurationResources`

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

Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject
`getLog`

Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
`enableLogging`

Methods inherited from interface org.apache.avalon.framework.context.Contextualizable
`contextualize`

Methods inherited from interface org.apache.avalon.framework.service.Serviceable
`service`

Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable
`getId, setId`

Methods inherited from interface fr.gouv.culture.sdx.utils.Describable
`getDescription, setDescription`

Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable
`getEncoding, setEncoding`

Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable
`getLocale, getXmlLang, setLocale, setXmlLang`

Field Detail

### CURRENT_INDEX_DIR

    public java.lang.String CURRENT_INDEX_DIR

  The current directory name

### creationTimestamp

    protected java.util.Date creationTimestamp

  The creation date of this index

### lastModificationTimestamp

    protected long lastModificationTimestamp

  The last modification timestamp of this index

### lastModFile

    protected java.io.File lastModFile

  The "last-modification-timestamp" file

### ACTION_ADD_DOCUMENT

    public static final int ACTION_ADD_DOCUMENT

  int representation of indexing action for adding a document.

  See Also:
    Constant Field Values

### DEFAULT_MAX_FIELD_LENGTH

    public static final int DEFAULT_MAX_FIELD_LENGTH

  Defaults for IndexWriter parameters; these are based on lucene defaults

  See Also:
    Constant Field Values

### DEFAULT_MAX_MERGE_DOCS

    public static final int DEFAULT_MAX_MERGE_DOCS

  Defaults for IndexWriter parameters; these are based on lucene defaults

  See Also:
    Constant Field Values

### DEFAULT_MERGE_FACTOR

    public static final int DEFAULT_MERGE_FACTOR

  Defaults for IndexWriter parameters; these are based on lucene defaults

  See Also:
    Constant Field Values

Constructor Detail

### LuceneIndex

    public LuceneIndex(java.io.File dir,
                       java.lang.String host,
                       java.lang.Integer port,
                       java.lang.String appId,
                       java.lang.String dbId)
                throws SDXException

  Builds an index with fields definition and a path to the index files.

  Parameters:
    `dir` - A directory where the index is kept.
    `host` -
    `port` -
    `appId` -
    `dbId` -
  Throws:
    `SDXException`

### LuceneIndex

    public LuceneIndex(java.io.File dir,
                       java.lang.String host,
                       java.lang.Integer port,
                       java.lang.String appId,
                       java.lang.String dbId,
                       boolean useCompoundFiles)
                throws SDXException

Parameters:
  `dir` -
  `host` -
  `port` -
  `appId` -
  `dbId` -
  `useCompoundFiles` -
Throws:
  `SDXException`

### LuceneIndex

    public LuceneIndex(LuceneIndex parentIndex,
                       java.io.File dir)

  Sub index constructor

  Parameters:
    `parentIndex` -
    `dir` -

### LuceneIndex

    public LuceneIndex(LuceneIndex parentIndex)

  Sub index constructor

  Parameters:
    `parentIndex` -

Method Detail

### configure

    public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
                   throws org.apache.avalon.framework.configuration.ConfigurationException

  Specified by:
    `configure` in interface `org.apache.avalon.framework.configuration.Configurable`
  Overrides:
    `configure` in class `AbstractSdxObject`
  Throws:
    `org.apache.avalon.framework.configuration.ConfigurationException`

### init

    public void init()
              throws SDXException

  Initializes the Lucene database.

  It the index exists, nothing is done here. If it is doesn't exist, it will be created.

  Throws:
    `SDXException`

### writeCreationTimestampFile

    protected void writeCreationTimestampFile()

  Creates the file that represents the creation timestamp of this Lucene index if relevant

### indexModified

    public void indexModified()
                       throws SDXException

  Throws:
    `SDXException`

### indexModified

    public void indexModified(boolean createLastModficationTimestampFile)
                       throws SDXException

  Deprecated. Use `indexModified()` instead.

  Throws:
    `SDXException`

### setDocCount

    protected void setDocCount(int i)

### docCount

    public int docCount()

### writeLastModificationTimestampFile

    public void writeLastModificationTimestampFile()

  Updates the date of the last modification timestamp of this Lucene index

  Updates the date of the last modification timestamp of this Lucene index. If the file does not exist, creates this file.

### writeLastModificationTimestampFile

    public void writeLastModificationTimestampFile(boolean create)

  Deprecated. Use `writeCreationTimestampFile()` instead.

### getFieldType

    public int getFieldType(java.lang.String name)

  Returns the type of a field.

  Parameters:
    `name` - The name of the field for which the type is desired.
  Returns:
    The int field code (see Field doc)

### getLocale

    public java.util.Locale getLocale(java.lang.String name)

  Returns the locale for a field.

  Parameters:
    `name` - The name of the field for which the Locale is desired.

### getDefaultField

    public Field getDefaultField()

  Returns the default field for this index.

### getField

    public Field getField(java.lang.String name)

  Returns a field given a name.

  Parameters:
    `name` - The name of the field for which the Field is desired.

### getMetaAnalyzer

    public MetaAnalyzer getMetaAnalyzer()

  Gets the MetaAnalyzer

### setMetaAnalyzer

    public void setMetaAnalyzer(MetaAnalyzer mAnalyzer)
                         throws SDXException

  Sets the MetaAnalyzer

  Parameters:
    `mAnalyzer` - A MetaAnalyzer object containing a FieldList object for this index.
  Throws:
    `SDXException`

### writeDocument

    public void writeDocument(org.apache.lucene.document.Document ldoc,
                              boolean batchIndex)
                       throws SDXException

  Stores a Lucene document within the database.

  Parameters:
    `ldoc` - The Lucene document to store.
    `batchIndex` - Indicates wheter a tempBatch index is taking place or not. Useful for efficiency of index optimizations
  Throws:
    `SDXException`

### writeDocument

    public void writeDocument(org.apache.lucene.document.Document ldoc,
                              boolean batchIndex,
                              boolean autoOptimize)
                       throws SDXException

  Stores a Lucene document within the database.

  Parameters:
    `ldoc` - The Lucene document to store.
    `batchIndex` - Indicates wheter a tempBatch index is taking place or not. Useful for efficiency of index optimizations
    `autoOptimize` - Is the DocumentBase autoOptimize ?
  Throws:
    `SDXException`

### recycleLuceneIndexSearcher

    public void recycleLuceneIndexSearcher()
                                    throws SDXException

  Recycles the Lucene searcher for this index

  Throws:
    `SDXException`

### recycleIndexReader

    public void recycleIndexReader()
                            throws SDXException

  Recycles the Lucene reader for this index

  Throws:
    `SDXException`

### deleteDocument

    public void deleteDocument(java.lang.String docId)
                        throws SDXException

  Deletes a document from the index.

  Parameters:
    `docId` - The document's id.
  Throws:
    `SDXException`

### getQueryParser

    public QueryParser getQueryParser()
                               throws java.io.IOException,
                                      SDXException

  Throws:
    `java.io.IOException`
    `SDXException`

### getRemoteIndexName

    public java.lang.String getRemoteIndexName()

### freeResources

    public void freeResources()
                       throws java.io.IOException

  Free's the resources associated with this index USE WITH CARE!

  Overrides:
    `freeResources` in class `LuceneDataStore`
  Throws:
    `java.io.IOException` - Lucene IOExceptions

### setParameters

    public void setParameters(LuceneIndexParameters params)

  Sets the indexing parameters

  Parameters:
    `params` - The relevant parameters for this lucene index.

### getWriter

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

  Gets a writer for the Lucene index

  Overrides:
    `getWriter` in class `LuceneDataStore`
  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

  Overrides:
    `getWriter` in class `LuceneDataStore`
  Throws:
    `java.io.IOException`

### getSearcher

    public org.apache.lucene.search.Searchable getSearcher()

  Gets a Lucene searcher

  Ensures we have a correct Lucene searcher for this index. For that, we ensure that this index has not been modified since the last initialization of the current searcher. If so, we have to recycle the searcher.

  Overrides:
    `getSearcher` in class `LuceneDataStore`
  Returns:
    Searchable A Lucene searcher.

### getSearcher

    public org.apache.lucene.search.Searchable getSearcher(boolean automaticRecycle)

### getReader

    public org.apache.lucene.index.IndexReader getReader()
                                                  throws SDXException

  Gets a Lucene reader

  Ensures we have a correct Lucene reader for this index. For that, we ensure that this index has not been modified since the last initialization of the current reader. If so, we have to recycle the reader.

  Overrides:
    `getReader` in class `LuceneDataStore`
  Returns:
    IndexReader A Lucene reader
  Throws:
    `SDXException`

### getReader

    public org.apache.lucene.index.IndexReader getReader(boolean automaticRecycle)
                                                  throws SDXException

  Throws:
    `SDXException`

### recycleSearcherReader

    public void recycleSearcherReader()

  Recycles Lucene Searcher and Reader

### getFieldValue

    public java.lang.String getFieldValue(IndexableDocument doc,
                                          java.lang.String fieldName)
                                   throws SDXException

  Gets the value of a field.

  Parameters:
    `doc` - The Lucene document
    `fieldName` - The name of the field
  Returns:
    String The value of the field as a String
  Throws:
    `SDXException`

### getCreationDate

    public java.util.Date getCreationDate()

  Returns the creation date of this Lucene index.

  Returns:
    Date

### getLastModificationDate

    public java.util.Date getLastModificationDate()

  Returns the last modification date

  Returns the the last modification timestamp of this Lucene index as a Date.

  Returns:
    Date

### getLastModificationTimestamp

    public long getLastModificationTimestamp()

  Returns the last modification timestamp

  Returns:
    long

### toSAX

    public void toSAX(org.xml.sax.ContentHandler hdl)
               throws org.xml.sax.SAXException

  Specified by:
    `toSAX` in interface `org.apache.excalibur.xml.sax.XMLizable`
  Overrides:
    `toSAX` in class `AbstractSdxObject`
  Throws:
    `org.xml.sax.SAXException`

### getClassNameSuffix

    protected java.lang.String getClassNameSuffix()

  Description copied from class: `AbstractSdxObject`
  Sub classes should element this method to return their class name suffix for SAX output

  Specified by:
    `getClassNameSuffix` in class `AbstractSdxObject`

### optimize

    public void optimize()
                  throws SDXException

  Index file optimization

  Overrides:
    `optimize` in class `LuceneDataStore`
  Throws:
    `SDXException`

### mergeCurrentBatch

    public void mergeCurrentBatch()
                           throws SDXException

  Merges any batch in memory

  Throws:
    `SDXException`

### mergeCurrentBatch

    public void mergeCurrentBatch(boolean optimize)
                           throws SDXException

  Merges any batch in memory and optimize it if necessary

  Throws:
    `SDXException`

### isSubIndex

    public boolean isSubIndex()

  Tell if the index is a subIndex or not

### hasBeenModified

    public boolean hasBeenModified()

  Has Lucene index been modified

  Returns true if this Lucene index has been modified since the last modification timestamp.

  Returns:
    boolean

### backup

    public void backup(SaveParameters save_config)
                throws SDXException

  Save LuceneIndex files

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

### restore

    public void restore(SaveParameters save_config)
                 throws SDXException

  Restore LuceneIndex files

  Specified by:
    `restore` in interface `Saveable`
  Overrides:
    `restore` in class `LuceneDataStore`
  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-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.