Package com.jalios.jcms.search
Class LuceneCategorySearchEngine
java.lang.Object
com.jalios.jcms.search.LuceneDataSearchEngine
com.jalios.jcms.search.LuceneCategorySearchEngine
- All Implemented Interfaces:
JcmsConstants,CategorySearchEngine,JaliosConstants
public class LuceneCategorySearchEngine
extends LuceneDataSearchEngine
implements CategorySearchEngine, JcmsConstants
This
Architecture and notable points:
Possible Hooks/Modification:
CategorySearchEngine is reponsible for the indexing and searching of JCMS
content using lucene. Architecture and notable points:
- 1 lucene index per language:
WEB-INF/data/lucene/CategoriesIndices/<lang>/. - 1
Documentper indexedCategory. - Indices' optimization occurs using schedule specified by property
"search-engine.optimize-schedule"(jdring's AlarmEntry cron-like format)
Possible Hooks/Modification:
- Specify analyzer for each language:
Analyzer getAnalyzer(String lang);
- Since:
- jcms-5.5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jalios.jcms.search.LuceneDataSearchEngine
LuceneDataSearchEngine.IndexingLatch, LuceneDataSearchEngine.ReindexOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final StringThis variable is the attribute's key used by the LuceneCategorySearchEngine to set the matched categories HashSet in the QueryResultSet Attribute.static final Stringstatic final StringFields inherited from class com.jalios.jcms.search.LuceneDataSearchEngine
alarmMgr, BACKGROUND_PROCESS_MGR, channel, directoryName, engineName, ID_FIELD, INDEXING_DATE_EXTRAINFO, INDEXING_DATE_FIELD, langList, multilingualFields inherited from interface com.jalios.util.JaliosConstants
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_YEARFields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADVANCED_TAB, AJAX_MODE_ATTR, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, CLASS_PROPERTY, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, COUNTRY_SPRITE, CS_TYPOLOGY_ROOT_CAT_VID, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DATA_DIRECTORY, DEFAULT_PHOTO_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, GENERATIONAL_STORE_DIRECTORY, 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, IS_IN_FRONT_OFFICE, 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_MINI, PHOTO_MINI_HEIGHT, PHOTO_MINI_PROP_PREFIX, PHOTO_MINI_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, PHOTO_XLARGE, PHOTO_XLARGE_HEIGHT, PHOTO_XLARGE_PROP_PREFIX, PHOTO_XLARGE_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, RAW_CONTENT_ICON_PREFIX, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SECURITY_LOG_FILE, SESSION_AUTHORIZED_FILENAMES_SET, SPRITE_ICON_PREFIX, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, SUCCESS_MSG, SVG_ICON_PREFIX, SVGINLINE_ICON_PREFIX, SVGSPRITE_ICON_PREFIX, TEMPLATE_TAB, THEME_DIR, 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, TYPES_UNKNOWN_CLASS_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, UPLOAD_PERMISSION_COUNT_PROP_PREFIX, UPLOAD_PERMISSION_SIZE_PROP_PREFIX, URL_REGEXP, VID_LOGGED_MEMBER, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd givenCategoryto this lucene search engine.voidadd(Collection<Category> coll) Add givenCollectionofCategoryto this lucene search engine.protected voidaddKeywordField(org.apache.lucene.document.Document doc, Category cat, String lang, String fieldName, String fieldValue, boolean applyBoost) This methods create a unstored LuceneFieldwith the given field's value of the givenCategoryin the given language, and add into the givenDocument.protected voidaddUnStoredField(org.apache.lucene.document.Document doc, Category cat, String lang, String fieldName, String fieldValue, boolean applyBoost) This methods create a unstored LuceneFieldwith the given field's value of the givenCategoryin the given language, and add into the givenDocument.voidDelete givenCategoryfrom this lucene search engine.voiddelete(Collection<Category> coll) Delete givenCollectionofCategoryfrom this lucene search engine.protected DataIterator<Data> Returns aDataIteratorover allDataobjects to be indexed, filtered according to the givenLuceneDataSearchEngine.ReindexOptions.getIndexingDate(Category cat) Retrieve the Date at which the specified Category was indexed in the search engine.protected org.apache.log4j.LoggerReturns theLoggerused for all log messages emitted by this engine.static intRetrieve the maximum number of results allowed to be return for a search.protected AdminSearchEnginesHandler.ActionReturns theAdminSearchEnginesHandler.Actionto use when starting anAdminSearchEngineProcessfor a full reindex.protected voidindexData(org.apache.lucene.index.IndexWriter writer, Data data, String lang, boolean isFullReindexing) This methods index the given Category in the given language, into the given index writer.booleansearch(QueryHandler qh, HashSet<? extends Publication> pubSet, QueryResultSet resultSet) Perform a full-text search.Find Category matching the specified QueryHandler search options (uses mainly the text search param)searchCategories(org.apache.lucene.search.Query query) Find Category matching the specified lucene QueryvoidUpdate givenCategoryin this lucene search engine.voidupdate(Collection<Category> coll) Update givenCollectionofCategoryin this lucene search engine.Methods inherited from class com.jalios.jcms.search.LuceneDataSearchEngine
acquireSearcher, addData, addDataCollection, clearIndices, createSnapshot, deleteData, deleteDataCollection, getAnalyzer, getDirectory, getIndexingDate, getIndexingDate, getIndexingLatch, getIndexWriter, getLastOptimizeDateSinceRestart, getLastOptimizeDuration, getLastReindexDateSinceRestart, getLastReindexDuration, getLuceneDocument, getOperationStartTime, getPrimaryTerm, getProgressState, getSearcherManager, getSimilarity, getSortFieldName, index, index, isOperationRunning, optimizeIndices, reindex, reindexAll, releaseSearcher, remove, updateData, updateDataCollection
-
Field Details
-
MATCHED_CATEGORIES_ATTRIBUTE
This variable is the attribute's key used by the LuceneCategorySearchEngine to set the matched categories HashSet in the QueryResultSet Attribute.- See Also:
-
CATEGORY_ENGINE_NAME
- See Also:
-
CATEGORY_INDEX_DIRECTORY
- See Also:
-
NAME_FIELD
- See Also:
-
SYNONYMS_FIELD
- See Also:
-
DESCRIPTION_FIELD
- See Also:
-
ALLFIELDS_FIELD
- See Also:
-
scoring
-
-
Constructor Details
-
LuceneCategorySearchEngine
Initialize the Lucene Search Engine- Throws:
Exception- if error occurs during initialization
-
-
Method Details
-
add
Add givenCategoryto this lucene search engine.- Specified by:
addin interfaceCategorySearchEngine- Parameters:
cat- theCategoryto index .
-
update
Update givenCategoryin this lucene search engine.- Specified by:
updatein interfaceCategorySearchEngine- Parameters:
cat- theCategoryto reindex .
-
delete
Delete givenCategoryfrom this lucene search engine.- Specified by:
deletein interfaceCategorySearchEngine- Parameters:
cat- theCategoryto reindex .
-
add
Add givenCollectionofCategoryto this lucene search engine.- Specified by:
addin interfaceCategorySearchEngine- Parameters:
coll- theCollectionofCategoryto index .
-
update
Update givenCollectionofCategoryin this lucene search engine.- Specified by:
updatein interfaceCategorySearchEngine- Parameters:
coll- theCollectionofCategoryto reindex .
-
delete
Delete givenCollectionofCategoryfrom this lucene search engine.- Specified by:
deletein interfaceCategorySearchEngine- Parameters:
coll- theCollectionofCategoryto reindex .
-
getIndexingDate
Retrieve the Date at which the specified Category was indexed in the search engine.- Specified by:
getIndexingDatein interfaceCategorySearchEngine- Parameters:
cat- theCategoryfor which to retrieve the indexing date.- Returns:
- the indexing date of the category or null if was not indexed.
- Since:
- jcms-6.0.1
-
getReindexAllAction
Description copied from class:LuceneDataSearchEngineReturns theAdminSearchEnginesHandler.Actionto use when starting anAdminSearchEngineProcessfor a full reindex.- Specified by:
getReindexAllActionin classLuceneDataSearchEngine
-
search
public boolean search(QueryHandler qh, HashSet<? extends Publication> pubSet, QueryResultSet resultSet) Description copied from interface:CategorySearchEnginePerform a full-text search.- Specified by:
searchin interfaceCategorySearchEngine- Parameters:
qh- the Queryhandler in which to find search text and search options.pubSet- a HashSet containing all thePublicationto search.
if empty, search is not performed at all.
if null, allPublicationfound will be returned.
This set MUST NOT be modified by implementation.resultSet- theQueryResultSetthat must be filled with matchingPublication- Returns:
- true if a search was performed in the CategorySearchEngine. Useful to differenciate a query returning zero result from a query not performed due to missing paramerters (text for example).
-
getMaximumResults
public static int getMaximumResults()Retrieve the maximum number of results allowed to be return for a search.Can be configured using property
query.lucene.cat.max-results- Returns:
- a maximum number of result retrieve (result beyong this limit are ignored)
- Since:
- jcms-10.0.0
-
searchCategories
Find Category matching the specified QueryHandler search options (uses mainly the text search param)- Parameters:
qh- the QueryHandler used to store- Returns:
- a collection of Category, ordered by relevance
- Since:
- jcms-7.1
-
searchCategories
Find Category matching the specified lucene Query- Parameters:
query- a Lucene Query- Returns:
- a collection of Category, ordered by relevance
- Since:
- jcms-7.1
-
getLogger
protected org.apache.log4j.Logger getLogger()Description copied from class:LuceneDataSearchEngineReturns theLoggerused for all log messages emitted by this engine.- Specified by:
getLoggerin classLuceneDataSearchEngine- Returns:
Loggerof this engine.
-
getDataIterator
Description copied from class:LuceneDataSearchEngineReturns aDataIteratorover allDataobjects to be indexed, filtered according to the givenLuceneDataSearchEngine.ReindexOptions.- Specified by:
getDataIteratorin classLuceneDataSearchEngine- Parameters:
options- reindex configuration- Returns:
- a non-null
DataIterator
-
indexData
protected void indexData(org.apache.lucene.index.IndexWriter writer, Data data, String lang, boolean isFullReindexing) throws IOException This methods index the given Category in the given language, into the given index writer.- Specified by:
indexDatain classLuceneDataSearchEngine- Parameters:
writer- target Lucene writerdata- theDatato indexlang- ISO-639 language codeisFullReindexing- true if operation is for a full reindexing with a empty index, false if updating an existing index- Throws:
IOException- on I/O error
-
addUnStoredField
protected void addUnStoredField(org.apache.lucene.document.Document doc, Category cat, String lang, String fieldName, String fieldValue, boolean applyBoost) This methods create a unstored LuceneFieldwith the given field's value of the givenCategoryin the given language, and add into the givenDocument.- Parameters:
doc- the Lucene documentcat- the categorylang- the languagefieldName- the field's namefieldValue- the field's valueapplyBoost- whether to apply the boost, useful for appendable field in which case the boost should only be applied for the first element.
-
addKeywordField
protected void addKeywordField(org.apache.lucene.document.Document doc, Category cat, String lang, String fieldName, String fieldValue, boolean applyBoost) This methods create a unstored LuceneFieldwith the given field's value of the givenCategoryin the given language, and add into the givenDocument.- Parameters:
doc- the Lucene documentcat- the categorylang- the languagefieldName- the field's namefieldValue- the field's valueapplyBoost- whether to apply the boost, useful for appendable field in which case the boost should only be applied for the first element.
-