Overview | File | Class | Tree | Index | Help
| Jala 1.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class jala.IndexManager

    Object
       |
       +--jala.IndexManager

class jala.IndexManager

This class basically sits on top of a helma.Search.Index instance and provides methods for adding, removing and optimizing the underlying index. All methods generate jobs that are put into an internal queue which is processed asynchronously by a separate worker thread. This means all calls to add(), remove() and optimize() will return immediately, but the changes to the index will be done within a short delay. Please keep in mind to change the status of this IndexManager instance to REBUILDING before starting to rebuild the index, as this ensures that all add/remove/optimize jobs will stay in the queue and will only be processed after switching the status back to NORMAL. This ensures that objects that have been modified during a rebuilding process are re-indexed properly afterwards.
Defined in IndexManager.js
See:

- helma.Search.createIndex

Nested Class Summary
`<static class>` | `jala.IndexManager.Job`

Field Summary
`<static> <final> Number` | `MAXTRIES` Constant defining the maximum number of tries to add/remove an object to/from the underlying index.
`<static> <final> Number` | `NORMAL` Constant defining normal mode of this index manager.
`<static> <final> Number` | `REBUILDING` Constant defining rebuilding mode of this index manager.

Constructor Summary
`jala.IndexManager (<String> name, <helma.File> dir, <String> lang)` Constructs a new IndexManager object.

Method Summary
`Boolean` | `add(<helma.Search.Document> doc)` Queues the document object passed as argument for addition to the underlying index.
`void` | `log()` Helper function that prefixes every log message with the name of the IndexManager.
`Boolean` | `optimize()` Queues the optimization of the underlying index.
`Boolean` | `remove(<Number> id)` Queues the removal of all index documents whose identifier value ("id" by default) matches the number passed as argument.

Field Detail

### MAXTRIES

    <static> <final> Number MAXTRIES

Constant defining the maximum number of tries to add/remove an object to/from the underlying index.

See Also:
  Constant Field Values

### NORMAL

    <static> <final> Number NORMAL

Constant defining normal mode of this index manager.

See Also:
  Constant Field Values

### REBUILDING

    <static> <final> Number REBUILDING

Constant defining rebuilding mode of this index manager.

See Also:
  Constant Field Values

Constructor Detail

### jala.IndexManager

    jala.IndexManager(<String> name, <helma.File> dir, <String> lang)

Constructs a new IndexManager object.

Parameters:

`name` - The name of the index, which is the name of the directory the index already resides or will be created in.

`dir` - The base directory where this index's directory is already existing or will be created in.

`lang` - The language of the documents in this index. This leads to the proper Lucene analyzer being used for indexing documents.

See:

- helma.Search.createIndex

Method Detail

### add

    Boolean add(<helma.Search.Document> doc)

Queues the document object passed as argument for addition to the underlying index. This includes that all existing documents with the same identifier will be removed before the object passed as argument is added.

Parameters:

`doc` - The document object that should be added to the underlying index.

Returns:

True if the job was added successfully to the internal queue, false otherwise.

See:

- helma.Search.Document

### log

    void log()

Helper function that prefixes every log message with the name of the IndexManager.

Parameters:

`level` - An optional logging level. Accepted values

`msg` - The log message are "debug", "info", "warn" and "error".

### optimize

    Boolean optimize()

Queues the optimization of the underlying index.

Returns:

True if the optimizing job was added, false otherwise, which means that there is already an optimizing job waiting in the queue.

### remove

    Boolean remove(<Number> id)

Queues the removal of all index documents whose identifier value ("id" by default) matches the number passed as argument.

Parameters:

`id` - The identifier value

Returns:

True if the removal job was added successfully to the queue, false otherwise.

Overview | File | Class | Tree | Index | Help
| Jala 1.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008