Constructor
new Index(directory, analyzer)
Creates a new instance of helma.Search.Index
Parameters:
Name | Type | Description |
---|---|---|
directory |
org.apache.lucene.store.Directory | The directory where the Lucene index is located at. |
analyzer |
org.apache.lucene.analysis.Analyzer | The analyzer to use when modifying the index. |
- Source:
Methods
addDocument(doc)
Adds a document to the index.
Parameters:
Name | Type | Description |
---|---|---|
doc |
helma.Search.Document | The document to add to the index. |
- Source:
addDocuments(docs)
Adds all documents in the passed collection to this index.
Parameters:
Name | Type | Description |
---|---|---|
docs |
java.util.Hashtable | java.util.Vector | Array | The documents to add to the index. |
- Source:
addIndexes(dir)
Merges the indexes passed as argument into this one.
Parameters:
Name | Type | Description |
---|---|---|
dir |
org.apache.lucene.store.Directory | At least one index director to add to this index. |
- Source:
close()
Closes the underlying index directory for future operations.
- Source:
count(fieldName, fieldValue)
Returns the number of documents with the given field name and value.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String | The name of the field |
fieldValue |
String | The value of the field |
- Source:
Returns:
The number of documents
create()
Creates a new index. This will delete any existing index
files in the directory of this index.
- Source:
Returns:
True if creating the index was successful, false otherwise
getAnalyzer()
Returns the analyzer used within this index.
- Source:
Returns:
The analyzer used within this index.
getDirectory()
Returns the directory the underlying Lucene index is located at.
- Source:
Returns:
The directory of this index
getFieldNames()
Returns an array containing all field names in this index.
- Source:
Returns:
An array with the field names in this index.
getReader()
Returns an IndexReader instance. Due to locking issues an
IndexModifier should be used for deleting documents.
- Source:
Returns:
An IndexReader instance
getSearcher()
Returns a searcher for querying this index.
- Source:
Returns:
A searcher useable for querying the index.
getWriter(create, autoCommit)
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.
Parameters:
Name | Type | Description |
---|---|---|
create |
Boolean | True to create the index (overwriting an existing index), false to append to an existing index. Defaults to false |
autoCommit |
Boolean | Enables or disables auto commit (defaults to false) |
- Source:
Returns:
An IndexWriter instance.
isLocked()
Checks if the index is locked.
- Source:
Returns:
True if the underlying index is locked,
false otherwise.
optimize()
Optimizes the underlying index.
- Source:
removeDocument(fieldName, fieldValue)
Remove all documents from the index whose field-value
with the given name matches the passed value argument.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String | The name of the field |
fieldValue |
String | The value of the field. |
- Source:
removeDocuments(fieldName, values)
Removes all documents whose field with the given name matches
the values passed as argument.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String | The name of the field |
values |
java.util.Hashtable | java.util.Vector | Array | The values that define the documents that should be removed from the index. |
- Source:
size()
Returns the number of documents in this index.
- Source:
Returns:
The number of documents in this index.
unlock()
Unlocks the index. Use this with caution, as it removes
any active locks in the Lucene index, which might lead
to index corruption.
- Source:
updateDocument(docObj, 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:
Name | Type | Description |
---|---|---|
docObj |
helma.Search.Document | Document object to add to index. |
fieldName |
String | The name of the identifier field. |
- Source: