public abstract class LuceneDataSearchEngine extends java.lang.Object implements JcmsConstants
Data
using Lucene.Modifier and Type | Class and Description |
---|---|
static class |
LuceneDataSearchEngine.IndexingLatch
CountDownLatch used to be notified of the end of the next
indexing operation taking place on a Data.
|
Modifier and Type | Field and Description |
---|---|
protected AlarmManager |
alarmMgr |
protected Channel |
channel |
protected java.lang.String |
directoryName |
protected java.lang.String |
engineName |
static java.lang.String |
ID_FIELD |
protected java.lang.Object |
indexAccessLock |
static java.lang.String |
INDEXING_DATE_EXTRAINFO |
static java.lang.String |
INDEXING_DATE_FIELD |
protected java.util.List<java.lang.String> |
langList
Languages in which the engine index and search its content.
|
protected java.util.Map<java.lang.String,org.apache.lucene.store.FSDirectory> |
langToIndexDirMap
Lucene FSDirectory in which the engine index and search its content.
|
protected java.util.Map<java.lang.String,org.apache.lucene.index.IndexWriter> |
langToIndexWriterMap
Lucene IndexWriter reused for all write operation.
|
protected boolean |
multilingual |
static java.lang.String |
REVISION |
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, AJAX_MODE_ATTR, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, COUNTRY_SPRITE, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, GLYPH_ICON_PREFIX, ICON_ARCHIVE, ICON_ICON_PREFIX, ICON_LOCK, ICON_LOCK_STRONG, ICON_PREFIX_PROP, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JCMS_TOASTR_COLLECTION, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LANG_SPRITE, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, ORGANIZATION_ROOT_GROUP_PROP, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_PROP_PREFIX, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_PROP_PREFIX, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_PROP_PREFIX, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_PROP_PREFIX, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_PROP_PREFIX, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, SPRITE_ICON_PREFIX, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, SUCCESS_MSG, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, TTCARD_MEDIA_HEIGHT, TTCARD_MEDIA_WIDTH, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
Modifier | Constructor and Description |
---|---|
protected |
LuceneDataSearchEngine(java.lang.String engineName,
java.lang.String directoryName,
boolean multilingual)
Construct a new Lucene Data Search Engine given a directory name.
|
Modifier and Type | Method and Description |
---|---|
protected org.apache.lucene.search.IndexSearcher |
acquireSearcher(java.lang.String[] languages,
java.lang.String defaultLanguage)
Acquire a Searcher to search in the specified language
|
protected void |
addData(Data data)
Add given
Data to this lucene search engine. |
protected void |
addDataCollection(java.util.Collection<? extends Data> coll)
Add given
Collection of Data to this lucene search engine. |
protected void |
clearIndices()
Delete all
Document from all indices (overwrite existing index with a new one). |
protected void |
clearSearcher()
Close current searchers and clear it for future renewal.
|
protected void |
deleteData(Data data)
Delete given
Data from this lucene search engine. |
protected void |
deleteDataCollection(java.util.Collection<? extends Data> coll)
Delete given
Collection of Data from this lucene search engine. |
protected abstract com.jalios.jcms.search.DataIterator<Data> |
getAllDataIterator()
This methods must be implemented by the LuceneSearchEngine.
|
org.apache.lucene.analysis.Analyzer |
getAnalyzer(java.lang.String lang,
boolean isIndexing)
Expert : Retrieve the lucene Analyzer to use during search and indexing.
|
org.apache.lucene.store.FSDirectory |
getDirectory(java.lang.String lang)
Expert: Returns the lucene directory used for the specified language.
|
java.util.Date |
getIndexingDate(Data data)
Retrieve the Date at which the specified Data was indexed in
the main language of the site.
|
java.util.Date |
getIndexingDate(Data data,
java.lang.String lang)
Returns the date at which the specified Data has
been indexed for the specified language.
|
LuceneDataSearchEngine.IndexingLatch |
getIndexingLatch(Data data)
Retrieve a new IndexingLatch useful to be notified of the end of the next
indexing operation to take place on the specified Data.
|
org.apache.lucene.index.IndexWriter |
getIndexWriter(java.lang.String lang)
Expert: Returns the lucene writer used for the specified language.
|
java.util.Date |
getLastOptimizeDateSinceRestart() |
long |
getLastOptimizeDuration() |
java.util.Date |
getLastReindexDateSinceRestart() |
long |
getLastReindexDuration() |
protected abstract org.apache.log4j.Logger |
getLogger()
This methods must be implemented by the LuceneSearchEngine.
|
org.apache.lucene.document.Document |
getLuceneDocument(Data data,
java.lang.String lang)
Returns the lucene Document corresponding to the specified Data
in the index of the the specified language.
|
long |
getOperationStartTime() |
protected org.apache.lucene.index.Term |
getPrimaryTerm(Data data)
Retrieve the a lucene Terme suitable for use as primary key when
searching/removing/updating a unique lucene document for the specified data
|
int |
getProgressState() |
org.apache.lucene.search.SearcherManager |
getSearcherManager(java.lang.String lang)
Expert: Returns the lucene SearcherManager used for the specified language.
|
org.apache.lucene.search.similarities.Similarity |
getSimilarity()
Expert : Returns the Similarity implementation to be used by Searcher of this LuceneDataSearchEngine.
|
protected void |
index(org.apache.lucene.index.IndexWriter writer,
java.util.Collection<? extends Data> coll,
java.lang.String lang)
Expert : Index a
Collection of Data into lucene. |
protected void |
index(org.apache.lucene.index.IndexWriter writer,
java.util.Iterator<? extends Data> iterator,
int iteratorSize,
java.lang.String lang)
Expert : Index all
Data returned by the specified Iterator into lucene. |
protected abstract void |
indexData(org.apache.lucene.index.IndexWriter writer,
Data data,
java.lang.String lang)
This methods must be implemented by the LuceneSearchEngine.
|
boolean |
isOperationRunning() |
void |
optimizeIndices()
Optimize all incides of the LuceneSearchEngine.
|
void |
reindexAll()
Clears the lucene indices of this searchengine, reindex all content
retrieved using protected method getAllDataIterator().
|
protected void |
releaseSearcher(java.lang.String[] languages,
java.lang.String defaultLanguage,
org.apache.lucene.search.IndexSearcher searcher)
Release the specified searcher, which was created for specified language.
|
protected void |
remove(org.apache.lucene.index.IndexWriter writer,
java.util.Collection<? extends Data> coll,
java.lang.String lang)
Expert: Remove a
Collection of Data from the lucene index. |
protected void |
updateData(Data data)
Update given
Data in this lucene search engine. |
protected void |
updateDataCollection(java.util.Collection<? extends Data> coll)
Update given
Collection of Data in this lucene search engine. |
public static final java.lang.String REVISION
public static final java.lang.String ID_FIELD
public static final java.lang.String INDEXING_DATE_FIELD
public static final java.lang.String INDEXING_DATE_EXTRAINFO
protected final Channel channel
protected final AlarmManager alarmMgr
protected final java.lang.String engineName
protected final java.lang.String directoryName
protected final boolean multilingual
protected final java.util.List<java.lang.String> langList
protected final java.util.Map<java.lang.String,org.apache.lucene.store.FSDirectory> langToIndexDirMap
protected final java.util.Map<java.lang.String,org.apache.lucene.index.IndexWriter> langToIndexWriterMap
protected final java.lang.Object indexAccessLock
protected LuceneDataSearchEngine(java.lang.String engineName, java.lang.String directoryName, boolean multilingual) throws java.lang.Exception
engineName
- the name of the engine (eg "Publication", "Member", "Category")directoryName
- the name of the directory to create (eg Publicationmultilingual
- true to use one index per language, false to use only one indexjava.lang.Exception
- on any errorprotected void index(org.apache.lucene.index.IndexWriter writer, java.util.Collection<? extends Data> coll, java.lang.String lang) throws java.io.IOException
Collection
of Data
into lucene. writer
- The Lucene directory writer with which data should be addedcoll
- a collection of Data, must not be nulllang
- the language in which data are being addedjava.io.IOException
- on io errorprotected void index(org.apache.lucene.index.IndexWriter writer, java.util.Iterator<? extends Data> iterator, int iteratorSize, java.lang.String lang) throws java.io.IOException
Data
returned by the specified Iterator
into lucene. writer
- The Lucene directory writer with which data should be addediterator
- a iterator of Data, must not be nulllang
- the language in which data are being addedjava.io.IOException
- on io errorprotected void remove(org.apache.lucene.index.IndexWriter writer, java.util.Collection<? extends Data> coll, java.lang.String lang) throws java.io.IOException
Collection
of Data
from the lucene index. writer
- The Lucene directory writer with which data should be removedcoll
- a collection of Data, must not be nulljava.io.IOException
- if the directory could not be opened or deletion could not be performedprotected org.apache.lucene.index.Term getPrimaryTerm(Data data)
public org.apache.lucene.store.FSDirectory getDirectory(java.lang.String lang)
lang
- the language of JCMS (ISO-639) in which to retrieve the DirectoryFSDirectory
of the specified language or null if no
Directory is available for this language.public org.apache.lucene.index.IndexWriter getIndexWriter(java.lang.String lang)
lang
- the language of JCMS (ISO-639) in which to retrieve the IndexWriterIndexWriter
of the specified language or null if no
Directory is available for this language.public org.apache.lucene.search.SearcherManager getSearcherManager(java.lang.String lang)
lang
- the language of JCMS (ISO-639) in which to retrieve the IndexWriterSearcherManager
of the specified language or null if no
Directory is available for this language.public org.apache.lucene.analysis.Analyzer getAnalyzer(java.lang.String lang, boolean isIndexing)
lang
- the ISO-639 language code of the text analyzed, may be nullisIndexing
- true if the returned analyzer is to be used
for indexing, false in any other case (e.g. during search etc..)public org.apache.lucene.search.similarities.Similarity getSimilarity()
public org.apache.lucene.document.Document getLuceneDocument(Data data, java.lang.String lang)
data
- the Data being looked forlang
- the language in which to checkpublic java.util.Date getIndexingDate(Data data, java.lang.String lang)
data
- the Data being looked forlang
- the language in which to checkpublic java.util.Date getIndexingDate(Data data)
data
- the Data
for which to retrieve the indexing date.protected void addData(Data data)
Data
to this lucene search engine.
This method is asynchronous, the given data may not be (and will
certainly not be) available immediately after call.protected void updateData(Data data)
Data
in this lucene search engine.
This method is asynchronous, the given data may not be (and will
certainly not be) available immediately after call.protected void deleteData(Data data)
Data
from this lucene search engine.
This method is asynchronous, the given data may not be (and will
certainly not be) available immediately after call.protected void addDataCollection(java.util.Collection<? extends Data> coll)
Collection
of Data
to this lucene search engine.
This method is asynchronous, the given datas may not be (and will
certainly not be) available immediately after call.protected void updateDataCollection(java.util.Collection<? extends Data> coll)
Collection
of Data
in this lucene search engine.
This method is asynchronous, the given datas may not be (and will
certainly not be) available immediately after call.protected void deleteDataCollection(java.util.Collection<? extends Data> coll)
Collection
of Data
from this lucene search engine.
This method is asynchronous, the given datas may not be (and will
certainly not be) available immediately after call.protected void clearIndices()
Document
from all indices (overwrite existing index with a new one).
Warning: this operation is undoable!
It is run against the indexing thread, it will not return
as long as the indexing process is not done, and will block the
indexing thread from running when doing its job.public void optimizeIndices()
public java.util.Date getLastOptimizeDateSinceRestart()
public long getLastOptimizeDuration()
public void reindexAll() throws java.io.IOException
isOperationRunning()
and getProgressState()
.java.io.IOException
- if an error occurs during indexingpublic java.util.Date getLastReindexDateSinceRestart()
public long getLastReindexDuration()
protected org.apache.lucene.search.IndexSearcher acquireSearcher(java.lang.String[] languages, java.lang.String defaultLanguage) throws java.io.IOException
languages
- the language in which search is requesteddefaultLanguage
- language used if no languages were explicitely specified and if current language is not available either. (ISO-639 language code)java.io.IOException
protected void releaseSearcher(java.lang.String[] languages, java.lang.String defaultLanguage, org.apache.lucene.search.IndexSearcher searcher)
languages
- the language in which search was requesteddefaultLanguage
- language used if no languages were explicitely specified and if current language is not available either. (ISO-639 language code)searcher
- the searcher that was acquired through acquireSearcher(String[], String)
protected void clearSearcher()
public LuceneDataSearchEngine.IndexingLatch getIndexingLatch(Data data)
Data original = ... Data update = origina.getUpdateInstance(); // update.set(...) IndexingLatch latch = searchEngine.getIndexingLatch(original); update.performUpdate()...; latch.await();
data
- the Data that must be monitored for indexingpublic boolean isOperationRunning()
getProgressState()
public int getProgressState()
isOperationRunning()
public long getOperationStartTime()
isOperationRunning()
protected abstract org.apache.log4j.Logger getLogger()
Logger
of this engine.protected abstract com.jalios.jcms.search.DataIterator<Data> getAllDataIterator()
reindexAll()
.protected abstract void indexData(org.apache.lucene.index.IndexWriter writer, Data data, java.lang.String lang) throws java.io.IOException
java.io.IOException
Copyright © 2001-2017 Jalios SA. All Rights Reserved.