## helma.Search.Index

    Object
       |
       +--helma.Search.Index

Instances of this class represent a Lucene search index located in either a directory on disk or in RAM. This class provides various methods for modifying the underlying Lucene index.
Defined in Search.js

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Constructor Summary
`helma.Search.Index(<org.apache.lucene.store.Directory> directory, <org.apache.lucene.analysis.Analyzer> analyzer)` Creates a new instance of helma.Search.Index

Properties Summary
`<static> Number` | `LOCK_TIMEOUT` Constant containing the number of milliseconds the index will try to create an IndexModifier or IndexWriter in case it is currently locked.

Methods Summary
`void` | `addDocument(<helma.Search.Document> doc)` Adds a document to the index.
`void` | `addDocuments(<java.util.Hashtable|java.util.Vector|Array> docs, mergeFactor)` Adds all documents in the passed collection to this index.
`void` | `addIndexes(<org.apache.lucene.store.Directory> dir )` Merges the indexes passed as argument into this one.
`void` | `close()` Closes the underlying index directory for future operations.
`Boolean` | `create()` Creates a new index.
`org.apache.lucene.analysis.Analyer` | `getAnalyzer()` Returns the analyzer used within this index.
`org.apache.lucene.store.Directory` | `getDirectory()` Returns the directory the underlying Lucene index is located at.
`Array` | `getFieldNames()` Returns an array containing all field names in this index.
`org.apache.lucene.index.IndexModifier` | `getModifier(create)` Returns an IndexModifier instance for adding or deleting documents to resp.
`org.apache.lucene.index.IndexReader` | `getReader()` Returns an IndexReader instance.
`helma.Search.Searcher` | `getSearcher()` Returns a searcher for querying this index.
`org.apache.lucene.index.IndexWriter` | `getWriter(create)` Returns an IndexWriter instance that can be used to add documents to the underlying index or to perform various other modifying operations.
`Boolean` | `isLocked()` Checks if the index is locked.
`void` | `optimize()` Optimizes the underlying index.
`Number` | `removeDocument(<String> fieldName, <String> fieldValue)` Remove those documents from the index whose field-value with the given name matches the passed value argument.
`Array` | `removeDocuments(<String> fieldName, <java.util.Hashtable|java.util.Vector|Array> values)` Removes all documents whose field with the given name matches the values passed as argument.
`Number` | `size()` Returns the number of documents in this index.
`void` | `unlock()` Unlocks the index.
`void` | `updateDocument(<helma.Search.Document> docObj, <String> fieldName)` Updates the index with the document passed as argument.

Constructor Detail

### helma.Search.Index

    helma.Search.Index(<org.apache.lucene.store.Directory> directory, <org.apache.lucene.analysis.Analyzer> analyzer)

Creates a new instance of helma.Search.Index

Parameters:

`directory` - The directory where the Lucene index is located at.

`analyzer` - The analyzer to use when modifying the index.

Properties Detail

### LOCK_TIMEOUT

    <static> Number LOCK_TIMEOUT

Constant containing the number of milliseconds the index will try to create an IndexModifier or IndexWriter in case it is currently locked.

Method Detail

### addDocument

    void addDocument(<helma.Search.Document> doc)

Adds a document to the index.

Parameters:

`doc` - The document to add to the index.

### addDocuments

    void addDocuments(<java.util.Hashtable|java.util.Vector|Array> docs, mergeFactor)

Adds all documents in the passed collection to this index.

Parameters:

`docs` - The documents to add to the index.

### addIndexes

    void addIndexes(<org.apache.lucene.store.Directory> dir )

Merges the indexes passed as argument into this one.

Parameters:

`dir` - At least one index director to add to this index.

### close

    void close()

Closes the underlying index directory for future operations.

### create

    Boolean create()

Creates a new index. This will delete any existing index files in the directory of this index.

Returns:

True if creating the index was successful, false otherwise

### getAnalyzer

    org.apache.lucene.analysis.Analyer getAnalyzer()

Returns the analyzer used within this index.

Returns:

The analyzer used within this index.

### getDirectory

    org.apache.lucene.store.Directory getDirectory()

Returns the directory the underlying Lucene index is located at.

Returns:

The directory of this index

### getFieldNames

    Array getFieldNames()

Returns an array containing all field names in this index.

Returns:

An array with the field names in this index.

### getModifier

    org.apache.lucene.index.IndexModifier getModifier(create)

Returns an IndexModifier instance for adding or deleting documents to resp. from the underlying index. If the index is currently locked this method will try for the next two seconds to create the IndexModifier, otherwise it will throw an error.

Returns:

An IndexModifier instance.

### getReader

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

Returns an IndexReader instance. Due to locking issues an IndexModifier should be used for deleting documents.

Returns:

An IndexReader instance

### getSearcher

    helma.Search.Searcher getSearcher()

Returns a searcher for querying this index.

Returns:

A searcher useable for querying the index.

### getWriter

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

Returns an IndexWriter instance that can be used to add documents to the underlying index or to perform various other modifying operations. If the index is currently locked this method will try for the next two seconds to create the IndexWriter, otherwise it will throw an error.

Returns:

An IndexWriter instance.

### isLocked

    Boolean isLocked()

Checks if the index is locked.

Returns:

True if the underlying index is locked, false otherwise.

### optimize

    void optimize()

Optimizes the underlying index.

### removeDocument

    Number removeDocument(<String> fieldName, <String> fieldValue)

Remove those documents from the index whose field-value with the given name matches the passed value argument.

Parameters:

`fieldName` - The name of the field

`fieldValue` - The value of the field.

Returns:

The number of documents that have been deleted.

### removeDocuments

    Array removeDocuments(<String> fieldName, <java.util.Hashtable|java.util.Vector|Array> values)

Removes all documents whose field with the given name matches the values passed as argument.

Parameters:

`fieldName` - The name of the field

`values` - The values that define the documents that should be removed from the index.

Returns:

An array containing the numbers of deleted documents for each field value.

### size

    Number size()

Returns the number of documents in this index.

Returns:

The number of documents in this index.

### unlock

    void unlock()

Unlocks the index. Use this with caution, as it removes any active locks in the Lucene index, which might lead to index corruption.

### updateDocument

    void updateDocument(<helma.Search.Document> docObj, <String> fieldName)

Updates the index with the document passed as argument. In contrast to addDocument() this removes any existing objects whose fieldName matches the one of the document object. Eg. if the document object has a field "Id" with the value "123", all document objects whose fieldName "Id" matches "123" will be removed from the index before.

Parameters:

`docObj` - Document object to add to index.

`fieldName` - The name of the identifier field.

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007