net.firstpartners.rp.back.index
Class BasicIndex

java.lang.Object
  extended by net.firstpartners.rp.back.index.BasicIndex
All Implemented Interfaces:
IIndexManager, IPlugin

public class BasicIndex
extends java.lang.Object
implements IIndexManager

Basic IndexManager to allow adding / searching on a (Lucene based) Index.

Author:
brownpa

Field Summary
(package private) static java.lang.String DEFAULT_DOCUM_AUTHOR
          Default document author
(package private) static java.lang.String DEFAULT_DOCUM_PATH
          Default document path
private  boolean isReady
          Flag to mark that index is in re-index process
protected  org.apache.log4j.Logger logger
          Logger for this class and subclasses
private  java.lang.String root
          Index root folder ${rp.root}/lucene
 
Constructor Summary
BasicIndex()
           
 
Method Summary
private  void addDocToIndex(org.apache.lucene.document.Document document)
          Add the document to the index
 void addToIndex(org.apache.lucene.document.Document document)
          Reindex the specified document
 java.lang.String getRoot()
          Get the root index folder
 boolean isReady()
          Get the ready flag of the index
 void onLoad()
          Carry out any initiation tasks ( create the index folder and create an empty empty index if already not exists one
 void optimize()
          Optimize the index (better results time for search process)
 void reindex(org.apache.lucene.document.Document[] documentsToUpdate)
          Remove the document from the index
 void reindex(java.lang.String id, double score)
          Uupdate the calculated score of the document with the specified id Score is already calculated by the category manager = (old_calcscore+weight)*categoryscore
 void removeFromIndex(java.lang.String uniqueId)
          Remove a piece of information from the index
 void setReady(boolean isReady)
          Set the ready flag of the inddex
 void setRoot(java.lang.String root)
          Set the root index folder
 void update(DocumStruct[] documentsToUpdate)
          Reindex of all the documents with the specified categoryname
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DOCUM_PATH

static final java.lang.String DEFAULT_DOCUM_PATH
Default document path

See Also:
Constant Field Values

DEFAULT_DOCUM_AUTHOR

static final java.lang.String DEFAULT_DOCUM_AUTHOR
Default document author

See Also:
Constant Field Values

logger

protected final org.apache.log4j.Logger logger
Logger for this class and subclasses


root

private java.lang.String root
Index root folder ${rp.root}/lucene


isReady

private boolean isReady
Flag to mark that index is in re-index process

Constructor Detail

BasicIndex

public BasicIndex()
Method Detail

optimize

public void optimize()
Optimize the index (better results time for search process)

Specified by:
optimize in interface IIndexManager

reindex

public void reindex(java.lang.String id,
                    double score)
Uupdate the calculated score of the document with the specified id Score is already calculated by the category manager = (old_calcscore+weight)*categoryscore

Specified by:
reindex in interface IIndexManager
Parameters:
id - Document id
score - New score(categoryscore*calc_score) for the document

addToIndex

public void addToIndex(org.apache.lucene.document.Document document)
Reindex the specified document

Specified by:
addToIndex in interface IIndexManager
Parameters:
document - ID of the document to reindex

addDocToIndex

private void addDocToIndex(org.apache.lucene.document.Document document)
Add the document to the index

Parameters:
document -

update

public void update(DocumStruct[] documentsToUpdate)
Reindex of all the documents with the specified categoryname

Parameters:
documentsToUpdate - Name of the category to reindex

reindex

public void reindex(org.apache.lucene.document.Document[] documentsToUpdate)
Remove the document from the index

Specified by:
reindex in interface IIndexManager
Parameters:
documentsToUpdate -

removeFromIndex

public void removeFromIndex(java.lang.String uniqueId)
Remove a piece of information from the index

Specified by:
removeFromIndex in interface IIndexManager
Parameters:
uniqueId -

onLoad

public void onLoad()
Carry out any initiation tasks ( create the index folder and create an empty empty index if already not exists one

Specified by:
onLoad in interface IPlugin

isReady

public boolean isReady()
Get the ready flag of the index

Returns:
Returns rue if the index is in running process, false otherwise

setReady

public void setReady(boolean isReady)
Set the ready flag of the inddex

Parameters:
isReady - The isReady to set.

getRoot

public java.lang.String getRoot()
Get the root index folder

Specified by:
getRoot in interface IIndexManager
Returns:
Returns the root index folder

setRoot

public void setRoot(java.lang.String root)
Set the root index folder

Parameters:
root - The root to set.