Interface I_CmsSearchIndex

    • Method Detail

      • getContentIfUnchanged

        I_CmsExtractionResult getContentIfUnchanged​(CmsResource resource)
        The method should return the extraction result of a content from the index, if sure the content has not changed since last indexing. This will prevent re-extraction of the content. Preventing re-extraction saves time while indexing, e.g., if only meta-data of a content has changed. If no up-to-date content can be provided from the index, return null.
        Parameters:
        resource - the resource the content should be provided for.
        Returns:
        the up-to-date extraction result as gained from the index - if possible, or null, if no up-to-date extraction result can be obtained from the index.
      • getFieldConfigurationName

        java.lang.String getFieldConfigurationName()
        Returns the name of the field configuration used for this index.

        Returns:
        the name of the field configuration used for this index
      • getLocaleForResource

        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.

        Parameters:
        cms - the current OpenCms user context
        resource - the resource to check
        availableLocales - a list of locales supported by the resource
        Returns:
        the language locale for the given resource in this index
      • getSourceNames

        java.util.List<java.lang.String> getSourceNames()
        Returns all configured sources names of this search index.

        Returns:
        a list with all configured sources names of this search index
      • isExtractingContent

        boolean isExtractingContent()
        Returns true if full text is extracted by this index.

        Full text content extraction can be turned off in the index search configuration parameters in opencms-search.xml. Not extraction the full text information will highly improve performance.

        Returns:
        true if full text is extracted by this index
      • isLanguageDetection

        boolean isLanguageDetection()
        Returns the languageDetection.

        Returns:
        the languageDetection
      • isUpdatedIncremental

        boolean isUpdatedIncremental()
        Returns true in case this index is updated incremental.

        An index is updated incremental if the index rebuild mode as defined by getRebuildMode() is either set to "auto" or "offline". Moreover, at least one update must have been written to the index already.

        Returns:
        true in case this index is updated incremental
      • removeSourceName

        void removeSourceName​(java.lang.String sourceName)
        Removes an index source from this search index.

        Parameters:
        sourceName - the index source name to remove
      • setLocale

        void setLocale​(java.util.Locale locale)
        Sets the locale to index resources.

        Parameters:
        locale - the locale to index resources
      • addSourceName

        void addSourceName​(java.lang.String sourceName)
        Adds am index source to this search index.

        Parameters:
        sourceName - the index source name to add
      • checkConfiguration

        boolean checkConfiguration​(CmsObject cms)
        Checks is this index has been configured correctly.

        In case the check fails, the enabled property is set to false

        Parameters:
        cms - a OpenCms user context to perform the checks with (should have "Administrator" permissions)
        Returns:
        true in case the index is correctly configured and enabled after the check
        See Also:
        isEnabled()
      • createEmptyDocument

        I_CmsSearchDocument createEmptyDocument​(CmsResource resource)
        Creates an empty document that can be used by this search field configuration.

        Parameters:
        resource - the resource to create the document for
        Returns:
        a new and empty document
      • excludeFromIndex

        boolean excludeFromIndex​(CmsObject cms,
                                 CmsResource resource)
        Checks if the provided resource should be excluded from this search index.

        Parameters:
        cms - the OpenCms context used for building the search index
        resource - the resource to index
        Returns:
        true if the resource should be excluded, false if it should be included in this index
      • getDocumentFactory

        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.

        A resource is indexed if the following is all true:

        1. The index contains at last one index source matching the root path of the given resource.
        2. For this matching index source, the document type factory needed by the resource is also configured.
        Parameters:
        res - the resource to check
        Returns:
        he document type factory used for the given resource in this index, or null in case the resource is not indexed by this index
      • getIndexWriter

        I_CmsIndexWriter getIndexWriter​(I_CmsReport report,
                                        boolean create)
                                 throws CmsIndexException
        Returns a new index writer for this index.

        Parameters:
        report - the report to write error messages on
        create - if true a whole new index is created, if false an existing index is updated
        Returns:
        a new instance of IndexWriter
        Throws:
        CmsIndexException - if the index can not be opened
      • getLocale

        java.util.Locale getLocale()
        Returns the language locale of this index.

        Returns:
        the language locale of this index, for example "en"
      • getName

        java.lang.String getName()
        Gets the name of this index.

        Returns:
        the name of the index
      • getPath

        java.lang.String getPath()
        Returns the path where this index stores it's data in the "real" file system.

        Returns:
        the path where this index stores it's data in the "real" file system
      • getProject

        java.lang.String getProject()
        Gets the project of this index.

        Returns:
        the project of the index, i.e. "online"
      • getRebuildMode

        java.lang.String getRebuildMode()
        Get the rebuild mode of this index.

        Returns:
        the current rebuild mode
      • getSources

        java.util.List<CmsSearchIndexSourcegetSources()
        Returns all configured index sources of this search index.

        Returns:
        all configured index sources of this search index
      • isEnabled

        boolean isEnabled()
        Returns true if this index is currently disabled.

        Returns:
        true if this index is currently disabled
      • isInitialized

        boolean isInitialized()
        Returns a flag, indicating if the search index is successfully initialized.
        Returns:
        a flag, indicating if the search index is successfully initialized.
      • onIndexChanged

        void onIndexChanged​(boolean force)
        Method called by the search manager if the index has changed. Typically the index searcher is reset when the method is called.
        Parameters:
        force - if false the index might decide itself it it has to act on the change, if true it should act, even if itself cannot detect an index change.
      • setEnabled

        void setEnabled​(boolean enabled)
        Can be used to enable / disable this index.

        Parameters:
        enabled - the state of the index to set
      • setFieldConfigurationName

        void setFieldConfigurationName​(java.lang.String fieldConfigurationName)
        Sets the name of the field configuration used for this index.

        Parameters:
        fieldConfigurationName - the name of the field configuration to set
      • setLocaleString

        void setLocaleString​(java.lang.String locale)
        Sets the locale to index resources as a String.

        Parameters:
        locale - the locale to index resources
        See Also:
        setLocale(Locale)
      • setName

        void setName​(java.lang.String name)
              throws CmsIllegalArgumentException
        Sets the logical key/name of this search index.

        Parameters:
        name - the logical key/name of this search index
        Throws:
        CmsIllegalArgumentException - if the given name is null, empty or already taken by another search index
      • setProject

        void setProject​(java.lang.String project)
        Sets the name of the project used to index resources.

        Parameters:
        project - the name of the project used to index resources
      • setRebuildMode

        void setRebuildMode​(java.lang.String rebuildMode)
        Sets the rebuild mode of this search index.

        Parameters:
        rebuildMode - the rebuild mode of this search index {auto|manual}
      • shutDown

        void shutDown()
        Shuts down the search index.

        This will close the local Lucene index searcher instance.