public class LuceneSearchProvider extends Object implements SearchProvider
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_CONTEXTS
Create contexts also.
|
protected static org.apache.log4j.Logger |
log |
protected static String |
LUCENE_ATTACHMENTS |
protected static String |
LUCENE_AUTHOR |
protected static String |
LUCENE_ID |
protected static String |
LUCENE_PAGE_CONTENTS |
protected static String |
LUCENE_PAGE_KEYWORDS |
protected static String |
LUCENE_PAGE_NAME |
protected List<Object[]> |
m_updates |
static int |
MAX_SEARCH_HITS
The maximum number of hits to return from searches.
|
static String |
PROP_LUCENE_ANALYZER
Which analyzer to use.
|
static String[] |
SEARCHABLE_FILE_SUFFIXES
These attachment file suffixes will be indexed.
|
LATEST_VERSION
Constructor and Description |
---|
LuceneSearchProvider() |
Modifier and Type | Method and Description |
---|---|
protected void |
doFullLuceneReindex()
Performs a full Lucene reindex, if necessary.
|
Collection<SearchResult> |
findPages(String query,
int flags,
WikiContext wikiContext)
Searches pages using a particular combination of flags.
|
Collection<SearchResult> |
findPages(String query,
WikiContext wikiContext)
Search for pages matching a search query
|
protected String |
getAttachmentContent(Attachment att) |
protected String |
getAttachmentContent(String attachmentName,
int version)
Fetches the attachment content from the repository.
|
protected WikiEngine |
getEngine()
Returns the handling engine.
|
String |
getProviderInfo()
Return a valid HTML string for information.
|
void |
initialize(WikiEngine engine,
Properties props)
Initializes the page provider.
|
protected org.apache.lucene.document.Document |
luceneIndexPage(WikiPage page,
String text,
org.apache.lucene.index.IndexWriter writer)
Indexes page using the given IndexWriter.
|
void |
pageRemoved(WikiPage page)
Delete a page from the search index
|
void |
reindexPage(WikiPage page)
Adds a page-text pair to the lucene update queue.
|
protected void |
updateLuceneIndex(WikiPage page,
String text)
Updates the lucene index for a single page.
|
protected static final org.apache.log4j.Logger log
public static final String PROP_LUCENE_ANALYZER
public static final String[] SEARCHABLE_FILE_SUFFIXES
protected static final String LUCENE_ID
protected static final String LUCENE_PAGE_CONTENTS
protected static final String LUCENE_AUTHOR
protected static final String LUCENE_ATTACHMENTS
protected static final String LUCENE_PAGE_NAME
protected static final String LUCENE_PAGE_KEYWORDS
public static final int MAX_SEARCH_HITS
public static final int FLAG_CONTEXTS
public LuceneSearchProvider()
public void initialize(WikiEngine engine, Properties props) throws NoRequiredPropertyException, IOException
initialize
in interface WikiProvider
engine
- WikiEngine to own this providerprops
- A set of properties used to initialize this providerNoRequiredPropertyException
- If the provider needs a property which is not found in the property setIOException
- If there is an IO problemprotected WikiEngine getEngine()
protected void doFullLuceneReindex() throws IOException
IOException
- If there's a problem during indexingprotected String getAttachmentContent(String attachmentName, int version)
attachmentName
- Name of the attachment.version
- The version of the attachment.protected String getAttachmentContent(Attachment att)
att
- Attachment to get content for. Filename extension is used to determine the type of the attachment.protected void updateLuceneIndex(WikiPage page, String text)
page
- The WikiPage to checktext
- The page text to index.protected org.apache.lucene.document.Document luceneIndexPage(WikiPage page, String text, org.apache.lucene.index.IndexWriter writer) throws IOException
page
- WikiPagetext
- Page text to indexwriter
- The Lucene IndexWriter to use for indexingIOException
- If there's an indexing problempublic void pageRemoved(WikiPage page)
pageRemoved
in interface SearchProvider
page
- Page to remove from search indexpublic void reindexPage(WikiPage page)
reindexPage
in interface SearchProvider
page
- WikiPage to add to the update queue.public Collection<SearchResult> findPages(String query, WikiContext wikiContext) throws ProviderException
findPages
in interface SearchProvider
query
- query to search forwikiContext
- the context within which to run the searchProviderException
- if the search provider failed.public Collection<SearchResult> findPages(String query, int flags, WikiContext wikiContext) throws ProviderException
query
- The query to perform in Lucene query languageflags
- A set of flagsProviderException
- if there is a problem with the backendpublic String getProviderInfo()
getProviderInfo
in interface WikiProvider
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.