Class LuceneSearchProvider

    • Method Detail

      • initialize

        public void initialize​(Engine engine,
                               java.util.Properties props)
                        throws NoRequiredPropertyException,
                               java.io.IOException
        Initializes the page provider.
        Specified by:
        initialize in interface WikiProvider
        Parameters:
        engine - Engine to own this provider
        props - A set of properties used to initialize this provider
        Throws:
        NoRequiredPropertyException - If the provider needs a property which is not found in the property set
        java.io.IOException - If there is an IO problem
      • getEngine

        protected Engine getEngine()
        Returns the handling engine.
        Returns:
        Current Engine
      • doFullLuceneReindex

        protected void doFullLuceneReindex()
                                    throws java.io.IOException
        Performs a full Lucene reindex, if necessary.
        Throws:
        java.io.IOException - If there's a problem during indexing
      • getAttachmentContent

        protected java.lang.String getAttachmentContent​(java.lang.String attachmentName,
                                                        int version)
        Fetches the attachment content from the repository. Content is flat text that can be used for indexing/searching or display
        Parameters:
        attachmentName - Name of the attachment.
        version - The version of the attachment.
        Returns:
        the content of the Attachment as a String.
      • getAttachmentContent

        protected java.lang.String getAttachmentContent​(Attachment att)
        Parameters:
        att - Attachment to get content for. Filename extension is used to determine the type of the attachment.
        Returns:
        String representing the content of the file. FIXME This is a very simple implementation of some text-based attachment, mainly used for testing. This should be replaced /moved to Attachment search providers or some other 'pluggable' way to search attachments
      • updateLuceneIndex

        protected void updateLuceneIndex​(Page page,
                                         java.lang.String text)
        Updates the lucene index for a single page.
        Parameters:
        page - The WikiPage to check
        text - The page text to index.
      • luceneIndexPage

        protected org.apache.lucene.document.Document luceneIndexPage​(Page page,
                                                                      java.lang.String text,
                                                                      org.apache.lucene.index.IndexWriter writer)
                                                               throws java.io.IOException
        Indexes page using the given IndexWriter.
        Parameters:
        page - WikiPage
        text - Page text to index
        writer - The Lucene IndexWriter to use for indexing
        Returns:
        the created index Document
        Throws:
        java.io.IOException - If there's an indexing problem
      • pageRemoved

        public void pageRemoved​(Page page)
        Delete a page from the search index.
        Specified by:
        pageRemoved in interface SearchProvider
        Parameters:
        page - Page to remove from search index.
      • reindexPage

        public void reindexPage​(Page page)
        Adds a page-text pair to the lucene update queue. Safe to call always
        Specified by:
        reindexPage in interface SearchProvider
        Parameters:
        page - WikiPage to add to the update queue.
      • findPages

        public java.util.Collection<SearchResultfindPages​(java.lang.String query,
                                                            Context wikiContext)
                                                     throws ProviderException
        Search for pages matching a search query.
        Specified by:
        findPages in interface SearchProvider
        Parameters:
        query - query to search for
        wikiContext - the context within which to run the search
        Returns:
        collection of pages that match query
        Throws:
        ProviderException - if the search provider failed.
      • findPages

        public java.util.Collection<SearchResultfindPages​(java.lang.String query,
                                                            int flags,
                                                            Context wikiContext)
                                                     throws ProviderException
        Searches pages using a particular combination of flags.
        Parameters:
        query - The query to perform in Lucene query language
        flags - A set of flags
        Returns:
        A Collection of SearchResult instances
        Throws:
        ProviderException - if there is a problem with the backend
      • getProviderInfo

        public java.lang.String getProviderInfo()
        Return a valid HTML string for information. May be anything.
        Specified by:
        getProviderInfo in interface WikiProvider
        Returns:
        A string describing the provider.