|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.opencms.search.CmsSearchIndex
org.opencms.search.solr.CmsSolrIndex
public class CmsSolrIndex
Implements the search within an Solr index.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.opencms.search.CmsSearchIndex |
|---|
CmsSearchIndex.LazyContentReader |
| Field Summary | |
|---|---|
protected static int |
DEBUG_PADDING_RIGHT
A constant for debug formatting outpu. |
static java.lang.String |
DEFAULT_INDEX_NAME_OFFLINE
The name of the default Solr Offline index. |
static java.lang.String |
DEFAULT_INDEX_NAME_ONLINE
The name of the default Solr Online index. |
static java.lang.String |
POST_PROCESSOR
Constant for additional parameter to set the post processor class name. |
static java.lang.String |
PROPERTY_SEARCH_EXCLUDE_VALUE_SOLR
The solr exclude property. |
| Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler |
|---|
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD |
| Constructor Summary | |
|---|---|
CmsSolrIndex()
Default constructor. |
|
CmsSolrIndex(java.lang.String name)
Public constructor to create a Solr index. |
|
| Method Summary | |
|---|---|
void |
addConfigurationParameter(java.lang.String key,
java.lang.String value)
Adds a parameter. |
I_CmsSearchDocument |
createEmptyDocument(CmsResource resource)
Creates an empty document that can be used by this search field configuration. |
protected java.lang.String |
createIndexBackup()
Creates a backup of this index for optimized re-indexing of the whole content. |
I_CmsIndexWriter |
createIndexWriter(boolean create,
I_CmsReport report)
Creates a new index writer. |
protected boolean |
excludeFromIndex(CmsObject cms,
CmsResource resource)
Checks if the provided resource should be excluded from this search index. |
CmsParameterConfiguration |
getConfiguration()
Returns the parameters of this configurable class instance, or null if the class does not need any parameters. |
I_CmsSearchDocument |
getDocument(java.lang.String fieldname,
java.lang.String term)
Returns the first document where the given term matches the selected index field. |
I_CmsDocumentFactory |
getDocumentFactory(CmsResource res)
Returns the document type factory used for the given resource in this index, or null
in case the resource is not indexed by this index. |
java.util.Locale |
getLocaleForResource(CmsObject cms,
CmsResource resource,
java.util.List<java.util.Locale> availableLocales)
Returns the language locale for the given resource in this index. |
I_CmsSolrPostSearchProcessor |
getPostProcessor()
Returns the search post processor. |
static java.lang.String |
getType(CmsObject cms,
java.lang.String rootPath)
Returns the resource type for the given root path. |
protected void |
indexSearcherClose()
Closes the index searcher for this index. |
protected void |
indexSearcherOpen(java.lang.String path)
Initializes the index searcher for this index. |
protected void |
indexSearcherUpdate()
Reopens the index search reader for this index, required after the index has been changed. |
void |
initialize()
Initializes the search index. |
protected boolean |
isIndexing(CmsResource res)
Checks if the given resource should be indexed by this index or not. |
CmsSearchResultList |
search(CmsObject cms,
CmsSearchParameters params)
Deprecated. |
CmsSolrResultList |
search(CmsObject cms,
CmsSolrQuery query)
Default search method. |
CmsSolrResultList |
search(CmsObject cms,
CmsSolrQuery query,
boolean ignoreMaxRows)
Performs a search on the Solr index Returns a list of 'OpenCms resource documents' ( CmsSearchResource) encapsulated within the class CmsSolrResultList. |
CmsSolrResultList |
search(CmsObject cms,
org.apache.solr.client.solrj.SolrQuery query)
Default search method. |
CmsSolrResultList |
search(CmsObject cms,
java.lang.String solrQuery)
Performs a search. |
void |
select(javax.servlet.ServletResponse response,
CmsObject cms,
CmsSolrQuery query,
boolean ignoreMaxRows)
Writes the response into the writer. |
void |
setPostProcessor(I_CmsSolrPostSearchProcessor postProcessor)
Sets the search post processor. |
void |
shutDown()
Shuts down the search index. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_INDEX_NAME_OFFLINE
public static final java.lang.String DEFAULT_INDEX_NAME_ONLINE
public static final java.lang.String POST_PROCESSOR
public static final java.lang.String PROPERTY_SEARCH_EXCLUDE_VALUE_SOLR
protected static final int DEBUG_PADDING_RIGHT
| Constructor Detail |
|---|
public CmsSolrIndex()
public CmsSolrIndex(java.lang.String name)
throws CmsIllegalArgumentException
name - the name for this index.
CmsIllegalArgumentException - if something goes wrong| Method Detail |
|---|
public static final java.lang.String getType(CmsObject cms,
java.lang.String rootPath)
cms - the current CMS contextrootPath - the root path of the resource to get the type for
public void addConfigurationParameter(java.lang.String key,
java.lang.String value)
CmsSearchIndex
addConfigurationParameter in interface I_CmsConfigurationParameterHandleraddConfigurationParameter in class CmsSearchIndexkey - the key/name of the parametervalue - the value of the parameterCmsSearchIndex.addConfigurationParameter(java.lang.String, java.lang.String)public I_CmsSearchDocument createEmptyDocument(CmsResource resource)
CmsSearchIndex
createEmptyDocument in class CmsSearchIndexresource - the resource to create the document for
CmsSearchIndex.createEmptyDocument(org.opencms.file.CmsResource)
public I_CmsIndexWriter createIndexWriter(boolean create,
I_CmsReport report)
CmsSearchIndex
createIndexWriter in class CmsSearchIndexcreate - if true a whole new index is created, if false an existing index is updatedreport - the report
CmsSearchIndex.createIndexWriter(boolean, org.opencms.report.I_CmsReport)public CmsParameterConfiguration getConfiguration()
I_CmsConfigurationParameterHandlernull if the class does not need any parameters.
getConfiguration in interface I_CmsConfigurationParameterHandlergetConfiguration in class CmsSearchIndexnull if the class does not need any parametersCmsSearchIndex.getConfiguration()
public I_CmsSearchDocument getDocument(java.lang.String fieldname,
java.lang.String term)
CmsSearchIndexUse this method to search for documents which have unique field values, like a unique id.
getDocument in class CmsSearchIndexfieldname - the field to search interm - the term to search for
CmsSearchIndex.getDocument(java.lang.String, java.lang.String)public I_CmsDocumentFactory getDocumentFactory(CmsResource res)
CmsSearchIndexnull
in case the resource is not indexed by this index.A resource is indexed if the following is all true:
getDocumentFactory in class CmsSearchIndexres - the resource to check
null
in case the resource is not indexed by this indexCmsSearchIndex.getDocumentFactory(org.opencms.file.CmsResource)
public java.util.Locale getLocaleForResource(CmsObject cms,
CmsResource resource,
java.util.List<java.util.Locale> availableLocales)
getLocaleForResource in class CmsSearchIndexcms - the current OpenCms user contextresource - the resource to checkavailableLocales - a list of locales supported by the resource
public I_CmsSolrPostSearchProcessor getPostProcessor()
public void initialize()
throws CmsSearchException
CmsSearchIndex
initialize in class CmsSearchIndexCmsSearchException - if the index source association failed or a configuration error occurredCmsSearchIndex.initialize()
@Deprecated
public CmsSearchResultList search(CmsObject cms,
CmsSearchParameters params)
#################
### DON'T USE ###
#################
search in class CmsSearchIndexcms - the current user's Cms objectparams - the parameters to use for the search
public CmsSolrResultList search(CmsObject cms,
CmsSolrQuery query)
throws CmsSearchException
cms - the current CMS objectquery - the query
CmsSearchException - if something goes wrongsearch(CmsObject, String)
public CmsSolrResultList search(CmsObject cms,
CmsSolrQuery query,
boolean ignoreMaxRows)
throws CmsSearchException
CmsSearchResource) encapsulated within the class CmsSolrResultList.
This list can be accessed exactly like an List which entries are
CmsSearchResource that extend CmsResource and holds the Solr
implementation of I_CmsSearchDocument as member. This enables you to deal
with the resulting list as you do with well known List and work on it's entries
like you do on CmsResource.
'5' and the current page
additionally the offset is added. The count of documents we don't have enough
permissions for grows with increasing page number, that's why we also multiply
the rows by the current page count.
cms - the current OpenCms contextignoreMaxRows - true to return all all requested rows, false to use max rowsquery - the OpenCms Solr query
CmsSearchException - if something goes wrongCmsSolrResultList,
CmsSearchResource,
I_CmsSearchDocument,
CmsSolrQuery
public CmsSolrResultList search(CmsObject cms,
org.apache.solr.client.solrj.SolrQuery query)
throws CmsSearchException
cms - the current CMS objectquery - the query
CmsSearchException - if something goes wrongsearch(CmsObject, String)
public CmsSolrResultList search(CmsObject cms,
java.lang.String solrQuery)
throws CmsSearchException
cms - the cms objectsolrQuery - the Solr query
CmsSearchException - if something goes wrongsearch(CmsObject, CmsSolrQuery, boolean)
public void select(javax.servlet.ServletResponse response,
CmsObject cms,
CmsSolrQuery query,
boolean ignoreMaxRows)
throws java.lang.Exception
NOTE: Currently not available for HTTP server.
response - the servlet responsecms - the CMS object to use for searchquery - the Solr queryignoreMaxRows - if to return unlimited results
java.lang.Exception - if there is no embedded serverpublic void setPostProcessor(I_CmsSolrPostSearchProcessor postProcessor)
postProcessor - the search post processor to setpublic void shutDown()
CmsSearchIndexThis will close the local Lucene index searcher instance.
shutDown in class CmsSearchIndexCmsSearchIndex.shutDown()protected java.lang.String createIndexBackup()
CmsSearchIndex
createIndexBackup in class CmsSearchIndexnull in case no backup was createdCmsSearchIndex.createIndexBackup()
protected boolean excludeFromIndex(CmsObject cms,
CmsResource resource)
CmsSearchIndex
excludeFromIndex in class CmsSearchIndexcms - the OpenCms context used for building the search indexresource - the resource to index
CmsSearchIndex.excludeFromIndex(CmsObject, CmsResource)protected void indexSearcherClose()
CmsSearchIndex
indexSearcherClose in class CmsSearchIndexCmsSearchIndex.indexSearcherClose()protected void indexSearcherOpen(java.lang.String path)
CmsSearchIndexIn case there is an index searcher still open, it is closed first.
For performance reasons, one instance of the index searcher should be kept for all searches. However, if the index is updated or changed this searcher instance needs to be re-initialized.
indexSearcherOpen in class CmsSearchIndexpath - the path to the index directoryCmsSearchIndex.indexSearcherOpen(java.lang.String)protected void indexSearcherUpdate()
CmsSearchIndex
indexSearcherUpdate in class CmsSearchIndexCmsSearchIndex.indexSearcherUpdate()protected boolean isIndexing(CmsResource res)
res - the resource candidate
true if the given resource should be indexed or false if not
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||