|
DLESE Tools v1.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.index.FileIndexingService
Indexes files into a SimpleLuceneIndex
and automatically
updates the index whenever changes to the files are made. This class uses a FileIndexingServiceWriter
to create the Lucene Document
s that are placed in the SimpleLuceneIndex
. This class looks for changes made to items in
a directory of files and updates the index automatically by adding, updating or
deleting items as appropriate. The frequency for update checkes is configurable. There
should be only one instance of this class for each SimpleLuceneIndex
that is being populated with this class.
Constructor Summary | |
---|---|
FileIndexingService(SimpleLuceneIndex index,
long updateFrequency,
boolean saveDeletes,
String idFieldToRemove,
String fileIndexingServiceDataDir)
Indexes files to the given SimpleLuceneIndex , checking
for changes in the files and reindexing them at the given update frequency. |
|
FileIndexingService(SimpleLuceneIndex index,
long updateFrequency,
String fileIndexingServiceDataDir)
Indexes files to the given SimpleLuceneIndex , checking
for changes in the files and reindexing them at the given update frequency. |
Method Summary | |
---|---|
boolean |
addDirectory(File srcDir,
FileIndexingServiceWriter documentWriter)
Adds a directory of files to be monitored for changes, or replaces the current one if one exists with the same absolute path. |
boolean |
addDirectory(String sourceFileDirectory,
FileIndexingServiceWriter documentWriter)
Adds a directory of files to be monitored for changes, or replaces the current one if one exists with the same absolute path. |
void |
changeUpdateFrequency(long updateFrequency)
Changes the frequency of reindexing to the new value. |
Object |
getAttribute(String key)
Gets an attribute Object from this FileIndexingService. |
static String |
getDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout: |
ArrayList |
getIndexingMessages()
Gets the last 10 indexing status messages. |
long |
getLastSyncTime()
Gets the lastSyncTime attribute of the FileIndexingService object |
int |
getNumRecordsToAdd()
Gets the numRecordsToAdd attribute of the FileIndexingService object |
int |
getNumRecordsToDelete()
Gets the numRecordsToDelete attribute of the FileIndexingService object |
int |
getNumRecordsToReplace()
Gets the numRecordsToReplace attribute of the FileIndexingService object |
static String |
getSimpleDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout: |
long |
getUpdateFrequency()
Gets the updateFrequency attribute of the FileIndexingService object |
boolean |
isDirectoryConfigured(File srcDir)
Determines whether the given directory is configured for indexing. |
void |
reindexDocs(Document[] docs,
boolean reindexAll)
Reindexes the given Documents. |
void |
reindexDocs(ResultDoc[] docs,
boolean reindexAll)
Reindexes the Documents in the given ResultDocs. |
int |
reindexDocs(String query,
boolean reindexAll)
Reindexes Documents managed by this FileIndexingService that match the given Lucene query. |
int |
reindexDocs(String field,
String[] terms,
boolean reindexAll)
Re-indexes all documents that match the given terms within the given field. |
int |
reindexDocs(String field,
String term,
boolean reindexAll)
Re-indexes all documents that match the given term within the given field. |
boolean |
removeDirectory(File srcDir)
Removes the files in the given directory from the index. |
boolean |
removeDirectory(String sourceFileDirectory)
Removes the files in the given directory from the index. |
void |
removeDocs(String field,
String[] terms,
FileIndexingServiceWriter docWriter)
Removes all documents that match the given terms within the given field. |
void |
removeDocs(String field,
String[] terms,
FileIndexingServiceWriter docWriter,
boolean saveDeletes)
Removes all documents that match the given terms within the given field. |
void |
removeDocs(String field,
String term,
FileIndexingServiceWriter docWriter)
Removes all documents that match the given term within the given field. |
void |
removeDocs(String field,
String term,
FileIndexingServiceWriter docWriter,
boolean saveDeletedRecords)
Removes all documents that match the given term within the given field. |
void |
setAttribute(String key,
Object attribute)
Sets an attribute Object that will be available for access in here and from the FileIndexingServiceWriters. |
static void |
setDebug(boolean db)
Sets the debug attribute object |
void |
setValidationEnabled(boolean validateFiles)
Sets whether or not to validate the files being indexed and create a validation report, which is indexed. |
void |
startTester(String docRoot,
String sourceFileDirectory)
Starts a FileMoveTester iff one is not already initialized. |
void |
startTimerThread(long updateFrequency)
Start or restarts the timer thread with the given update frequency. |
void |
stopTester()
Stops the FileMoveTester |
void |
stopTimerThread()
Stops the indexing timer thread. |
void |
synchIndexWithFiles(boolean background,
boolean reindexAll)
Updates the index to reflect the files in the directories this service is monitoring, with the option to run the update in the background. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileIndexingService(SimpleLuceneIndex index, long updateFrequency, String fileIndexingServiceDataDir)
SimpleLuceneIndex
, checking
for changes in the files and reindexing them at the given update frequency.
Validation of files is enabled by default.
index
- The SimpleLuceneIndex
that will
be populated and updated with Documents created from filesupdateFrequency
- The frequency by which files are checked for updates. A
negative number indicates no updates should be performed.setValidationEnabled(boolean validateFiles)
public FileIndexingService(SimpleLuceneIndex index, long updateFrequency, boolean saveDeletes, String idFieldToRemove, String fileIndexingServiceDataDir)
SimpleLuceneIndex
, checking
for changes in the files and reindexing them at the given update frequency.
Validation of files is enabled by default.
index
- The SimpleLuceneIndex
that will
be populated and updated with Documents created from filesupdateFrequency
- The frequency by which files are checked for updates. A
negative number indicates no updates should be performed.saveDeletes
- True to save removed documents in the index and mark them
deleted, else they will be removed from the index.idFieldToRemove
- An ID field whoes docs should be removed if found in
duplicate.setValidationEnabled(boolean validateFiles)
Method Detail |
public void setAttribute(String key, Object attribute)
key
- The key used to reference the attribute.attribute
- Any Java Object.FileIndexingServiceWriter
public Object getAttribute(String key)
key
- The key used to reference the attribute.
FileIndexingServiceWriter
public void changeUpdateFrequency(long updateFrequency)
startTimerThread(long updateFrequency)
.
updateFrequency
- The frequency by which files are checked for changes and
reindexed.public void startTimerThread(long updateFrequency)
changeUpdateFrequency(long updateFrequency)
.
updateFrequency
- The number of seconds between index updates.public void stopTimerThread()
public void setValidationEnabled(boolean validateFiles)
validateFiles
- True to validate, else false.FileIndexingServiceWriter.getValidationReport()
public boolean addDirectory(String sourceFileDirectory, FileIndexingServiceWriter documentWriter)
sourceFileDirectory
- The file direcory that will be monitored for updates.documentWriter
- The FileIndexingServiceWriter that is used to create new
Lucene Document entries for the files in the given directory.
public boolean addDirectory(File srcDir, FileIndexingServiceWriter documentWriter)
srcDir
- The file direcory that will be monitored for updates.documentWriter
- The FileIndexingServiceWriter that is used to create new
Lucene Document entries for the files in the given directory.
public boolean isDirectoryConfigured(File srcDir)
srcDir
- A directory of indexable files.
public boolean removeDirectory(String sourceFileDirectory)
addDirectory(File,FileIndexingServiceWriter)
method.
sourceFileDirectory
- The directory of files needing to be removed from the
index.
public boolean removeDirectory(File srcDir)
addDirectory(File,FileIndexingServiceWriter)
method.
srcDir
- The directory of files needing to be removed from the index.
public long getUpdateFrequency()
public long getLastSyncTime()
public int getNumRecordsToDelete()
public int getNumRecordsToAdd()
public int getNumRecordsToReplace()
public void synchIndexWithFiles(boolean background, boolean reindexAll)
background
- True to run this process as a background thread, else wait until
the update is done before returning.reindexAll
- DESCRIPTIONpublic final void removeDocs(String field, String term, FileIndexingServiceWriter docWriter)
SimpleLuceneIndex.removeDocs(String,String)
but is synchronized with other
operations occuring in this FileIndexinService and handles deletes accordingly.
field
- The field that is searched.term
- The term that is matched for removal.docWriter
- DESCRIPTIONpublic final void removeDocs(String field, String[] terms, FileIndexingServiceWriter docWriter)
SimpleLuceneIndex.removeDocs(String,String[])
but is synchronized with other
operations occuring in this FileIndexinService and handles deletes accordingly.
field
- The field that is searched.terms
- The terms that are matched for removal.docWriter
- DESCRIPTIONpublic final void removeDocs(String field, String term, FileIndexingServiceWriter docWriter, boolean saveDeletedRecords)
SimpleLuceneIndex.removeDocs(String,String)
but is
synchronized with other operations occuring in this FileIndexinService and handles
deletes accordingly.
field
- The field that is searched.term
- The term that is matched for removal.saveDeletedRecords
- True to save the removed documents in the index and mark
them deleted, else they will be removed from the index.docWriter
- DESCRIPTIONpublic final void removeDocs(String field, String[] terms, FileIndexingServiceWriter docWriter, boolean saveDeletes)
SimpleLuceneIndex.removeDocs(String,String[])
but is synchronized with other
operations occuring in this FileIndexinService and handles deletes accordingly.
field
- The field that is searched.terms
- The terms that are matched for removal.saveDeletes
- True to save the removed documents in the index and mark them
deleted, else they will be removed from the index.docWriter
- Writer used to perform the delete.public int reindexDocs(String field, String term, boolean reindexAll)
field
- The field that is searched.term
- The term that is matched for updates.reindexAll
- True to reindex all matching results, false to reindex only those
matches whoes files have been modified since the last update.
public int reindexDocs(String field, String[] terms, boolean reindexAll)
field
- The field that is searched.terms
- The terms that are matched for updates.reindexAll
- True to reindex all matching results, false to reindex only those
matches whoes files have been modified since the last update.
public int reindexDocs(String query, boolean reindexAll)
query
- A Lucene search query.reindexAll
- True to reindex all matching results, false to reindex only those
matches whoes files have been modified since the last update.
public void reindexDocs(Document[] docs, boolean reindexAll)
docs
- Lucene Documents from the same index that is managed by this
FileIndexingService.reindexAll
- True to reindex all matching results, false to reindex only those
matches whoes files have been modified since the last update.public void reindexDocs(ResultDoc[] docs, boolean reindexAll)
docs
- Lucene ResultDocs from the same index that is managed by this
FileIndexingService.reindexAll
- True to reindex all matching results, false to reindex only those
matches whoes files have been modified since the last update.public ArrayList getIndexingMessages()
public void startTester(String docRoot, String sourceFileDirectory)
docRoot
- The context document root as obtainied by calling
getServletContext().getRealPath("/");sourceFileDirectory
- DESCRIPTIONpublic void stopTester()
public static String getSimpleDateStamp()
public static String getDateStamp()
public static void setDebug(boolean db)
db
- The new debug value
|
DLESE Tools v1.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |