Class LuceneSearchProvider

java.lang.Object
org.apache.wiki.search.LuceneSearchProvider
All Implemented Interfaces:
org.apache.wiki.api.providers.WikiProvider, SearchProvider

public class LuceneSearchProvider extends Object implements SearchProvider
Interface for the search providers that handle searching the Wiki
Since:
2.2.21.
  • Field Details

  • Constructor Details

  • Method Details

    • initialize

      public void initialize(org.apache.wiki.api.core.Engine engine, Properties props) throws org.apache.wiki.api.exceptions.NoRequiredPropertyException, IOException
      Specified by:
      initialize in interface org.apache.wiki.api.providers.WikiProvider
      Throws:
      org.apache.wiki.api.exceptions.NoRequiredPropertyException
      IOException
    • getEngine

      protected org.apache.wiki.api.core.Engine getEngine()
      Returns the handling engine.
      Returns:
      Current Engine
    • doFullLuceneReindex

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

      protected String getAttachmentContent(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 String getAttachmentContent(org.apache.wiki.api.core.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(org.apache.wiki.api.core.Page page, 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(org.apache.wiki.api.core.Page page, String text, org.apache.lucene.index.IndexWriter writer) throws 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:
      IOException - If there's an indexing problem
    • pageRemoved

      public void pageRemoved(org.apache.wiki.api.core.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(org.apache.wiki.api.core.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 Collection<org.apache.wiki.api.search.SearchResult> findPages(String query, org.apache.wiki.api.core.Context wikiContext) throws org.apache.wiki.api.exceptions.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:
      org.apache.wiki.api.exceptions.ProviderException - if the search provider failed.
    • findPages

      public Collection<org.apache.wiki.api.search.SearchResult> findPages(String query, int flags, org.apache.wiki.api.core.Context wikiContext) throws org.apache.wiki.api.exceptions.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:
      org.apache.wiki.api.exceptions.ProviderException - if there is a problem with the backend
    • getProviderInfo

      Specified by:
      getProviderInfo in interface org.apache.wiki.api.providers.WikiProvider