public class CmsSolrIndex extends CmsSearchIndex
限定符和类型 | 字段和说明 |
---|---|
protected static int |
DEBUG_PADDING_RIGHT
A constant for debug formatting output.
|
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.
|
static int |
ROWS_MAX
Indicates the maximum number of documents from the complete result set to return.
|
A_PARAM_PREFIX, BACKUP_REINDEXING, DATES, DOC_META_FIELDS, EXCERPT, EXTRACT_CONTENT, IGNORE_EXPIRATION, LANGUAGEDETECTION, LUCENE_AUTO_COMMIT, LUCENE_RAM_BUFFER_SIZE_MB, LUCENE_VERSION, MAX_HITS, MAX_HITS_DEFAULT, MAX_YEAR_RANGE, PERMISSIONS, PRIORITY, PROPERTY_SEARCH_EXCLUDE_VALUE_ALL, PROPERTY_SEARCH_EXCLUDE_VALUE_GALLERY, REBUILD_MODE_AUTO, REBUILD_MODE_MANUAL, REBUILD_MODE_OFFLINE, TIME_RANGE, TYPE_XMLCONTENT, USE_ALL_LOCALE, VISITOR
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
构造器和说明 |
---|
CmsSolrIndex()
Default constructor.
|
CmsSolrIndex(java.lang.String name)
Public constructor to create a Solr index.
|
限定符和类型 | 方法和说明 |
---|---|
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)
已过时。
|
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 |
setSolrServer(org.apache.solr.client.solrj.SolrServer server)
Sets the Solr server used by this index.
|
void |
shutDown()
Shuts down the search index.
|
void |
spellCheck(javax.servlet.ServletResponse res,
CmsObject cms,
CmsSolrQuery q)
Executes a spell checking Solr query and returns the Solr query response.
|
addSourceName, appendCategoryFilter, appendDateCreatedFilter, appendDateLastModifiedFilter, appendPathFilter, appendResourceTypeFilter, checkConfiguration, createDateRangeFilter, equals, extendPathFilter, generateIndexDirectory, getAnalyzer, getDateRangeSpan, getDocument, getDocument, getFieldConfiguration, getFieldConfigurationName, getIndexWriter, getLocale, getLocaleString, getMaxHits, getMultiTermQueryFilter, getMultiTermQueryFilter, getMultiTermQueryFilter, getName, getPath, getPriority, getProject, getRebuildMode, getResource, getSearcher, getSourceNames, getSources, getTermQueryFilter, hashCode, hasReadPermission, indexSearcherClose, indexWriterUnlock, initConfiguration, isBackupReindexing, isCheckingPermissions, isCheckingTimeRange, isCheckPermissions, isCreatingExcerpt, isEnabled, isExtractingContent, isIgnoreExpiration, isInTimeRange, isLanguageDetection, isRequireViewPermission, isSortScoring, isUpdatedIncremental, needsPermissionCheck, removeIndexBackup, removeSourceName, setAnalyzer, setCheckPermissions, setEnabled, setFieldConfiguration, setFieldConfigurationName, setIgnoreExpiration, setIndexWriter, setLanguageDetection, setLocale, setLocaleString, setMaxHits, setName, setProject, setRebuildMode, setRequireViewPermission, toString
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
public static final int ROWS_MAX
protected static final int DEBUG_PADDING_RIGHT
public CmsSolrIndex()
public CmsSolrIndex(java.lang.String name) throws CmsIllegalArgumentException
name
- the name for this index.CmsIllegalArgumentException
- if something goes wrongpublic 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 forpublic void addConfigurationParameter(java.lang.String key, java.lang.String value)
CmsSearchIndex
addConfigurationParameter
在接口中 I_CmsConfigurationParameterHandler
addConfigurationParameter
在类中 CmsSearchIndex
key
- 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
在类中 CmsSearchIndex
resource
- the resource to create the document forCmsSearchIndex.createEmptyDocument(org.opencms.file.CmsResource)
public I_CmsIndexWriter createIndexWriter(boolean create, I_CmsReport report)
CmsSearchIndex
createIndexWriter
在类中 CmsSearchIndex
create
- if true
a whole new index is created, if false
an existing index is updatedreport
- the reportCmsSearchIndex.createIndexWriter(boolean, org.opencms.report.I_CmsReport)
public CmsParameterConfiguration getConfiguration()
I_CmsConfigurationParameterHandler
null
if the class does not need any parameters.getConfiguration
在接口中 I_CmsConfigurationParameterHandler
getConfiguration
在类中 CmsSearchIndex
null
if the class does not need any parametersCmsSearchIndex.getConfiguration()
public I_CmsSearchDocument getDocument(java.lang.String fieldname, java.lang.String term)
CmsSearchIndex
Use this method to search for documents which have unique field values, like a unique id.
getDocument
在类中 CmsSearchIndex
fieldname
- the field to search interm
- the term to search forCmsSearchIndex.getDocument(java.lang.String, java.lang.String)
public I_CmsDocumentFactory getDocumentFactory(CmsResource res)
CmsSearchIndex
null
in case the resource is not indexed by this index.A resource is indexed if the following is all true:
getDocumentFactory
在类中 CmsSearchIndex
res
- the resource to checknull
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
在类中 CmsSearchIndex
cms
- the current OpenCms user contextresource
- the resource to checkavailableLocales
- a list of locales supported by the resourcepublic I_CmsSolrPostSearchProcessor getPostProcessor()
public void initialize() throws CmsSearchException
CmsSearchIndex
initialize
在类中 CmsSearchIndex
CmsSearchException
- if the index source association failed or a configuration error occurredCmsSearchIndex.initialize()
@Deprecated public CmsSearchResultList search(CmsObject cms, CmsSearchParameters params)
#################
### DON'T USE ###
#################
search
在类中 CmsSearchIndex
cms
- the current user's Cms objectparams
- the parameters to use for the searchpublic CmsSolrResultList search(CmsObject cms, CmsSolrQuery query) throws CmsSearchException
cms
- the current CMS objectquery
- the queryCmsSearchException
- 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 queryCmsSearchException
- 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 queryCmsSearchException
- if something goes wrongsearch(CmsObject, String)
public CmsSolrResultList search(CmsObject cms, java.lang.String solrQuery) throws CmsSearchException
cms
- the cms objectsolrQuery
- the Solr queryCmsSearchException
- 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 resultsjava.lang.Exception
- if there is no embedded serverpublic void setPostProcessor(I_CmsSolrPostSearchProcessor postProcessor)
postProcessor
- the search post processor to setpublic void setSolrServer(org.apache.solr.client.solrj.SolrServer server)
server
- the server to setpublic void shutDown()
CmsSearchIndex
This will close the local Lucene index searcher instance.
shutDown
在类中 CmsSearchIndex
CmsSearchIndex.shutDown()
public void spellCheck(javax.servlet.ServletResponse res, CmsObject cms, CmsSolrQuery q) throws CmsSearchException
res
- the servlet responsecms
- the CMS objectq
- the queryCmsSearchException
- if something goes wrongprotected java.lang.String createIndexBackup()
CmsSearchIndex
createIndexBackup
在类中 CmsSearchIndex
null
in case no backup was createdCmsSearchIndex.createIndexBackup()
protected boolean excludeFromIndex(CmsObject cms, CmsResource resource)
CmsSearchIndex
excludeFromIndex
在类中 CmsSearchIndex
cms
- the OpenCms context used for building the search indexresource
- the resource to indexCmsSearchIndex.excludeFromIndex(CmsObject, CmsResource)
protected void indexSearcherClose()
CmsSearchIndex
protected void indexSearcherOpen(java.lang.String path)
CmsSearchIndex
In 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
在类中 CmsSearchIndex
path
- the path to the index directoryCmsSearchIndex.indexSearcherOpen(java.lang.String)
protected void indexSearcherUpdate()
CmsSearchIndex
protected boolean isIndexing(CmsResource res)
res
- the resource candidatetrue
if the given resource should be indexed or false
if not