public class LuceneSearchProvider extends java.lang.Object implements SearchProvider
| Modifier and Type | Field and Description |
|---|---|
static int |
FLAG_CONTEXTS
Create contexts also.
|
protected static org.apache.logging.log4j.Logger |
log |
protected static java.lang.String |
LUCENE_ATTACHMENTS |
protected static java.lang.String |
LUCENE_AUTHOR |
protected static java.lang.String |
LUCENE_ID |
protected static java.lang.String |
LUCENE_PAGE_CONTENTS |
protected static java.lang.String |
LUCENE_PAGE_KEYWORDS |
protected static java.lang.String |
LUCENE_PAGE_NAME |
protected java.util.List<java.lang.Object[]> |
m_updates |
static int |
MAX_SEARCH_HITS
The maximum number of hits to return from searches.
|
static java.lang.String |
PROP_LUCENE_ANALYZER
Which analyzer to use.
|
static java.lang.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.
|
java.util.Collection<SearchResult> |
findPages(java.lang.String query,
Context wikiContext)
Search for pages matching a search query.
|
java.util.Collection<SearchResult> |
findPages(java.lang.String query,
int flags,
Context wikiContext)
Searches pages using a particular combination of flags.
|
protected java.lang.String |
getAttachmentContent(Attachment att) |
protected java.lang.String |
getAttachmentContent(java.lang.String attachmentName,
int version)
Fetches the attachment content from the repository.
|
protected Engine |
getEngine()
Returns the handling engine.
|
java.lang.String |
getProviderInfo() |
void |
initialize(Engine engine,
java.util.Properties props) |
protected org.apache.lucene.document.Document |
luceneIndexPage(Page page,
java.lang.String text,
org.apache.lucene.index.IndexWriter writer)
Indexes page using the given IndexWriter.
|
void |
pageRemoved(Page page)
Delete a page from the search index.
|
void |
reindexPage(Page page)
Adds a page-text pair to the lucene update queue.
|
protected void |
updateLuceneIndex(Page page,
java.lang.String text)
Updates the lucene index for a single page.
|
protected static final org.apache.logging.log4j.Logger log
public static final java.lang.String PROP_LUCENE_ANALYZER
public static final java.lang.String[] SEARCHABLE_FILE_SUFFIXES
protected static final java.lang.String LUCENE_ID
protected static final java.lang.String LUCENE_PAGE_CONTENTS
protected static final java.lang.String LUCENE_AUTHOR
protected static final java.lang.String LUCENE_ATTACHMENTS
protected static final java.lang.String LUCENE_PAGE_NAME
protected static final java.lang.String LUCENE_PAGE_KEYWORDS
protected final java.util.List<java.lang.Object[]> m_updates
public static final int MAX_SEARCH_HITS
public static final int FLAG_CONTEXTS
public LuceneSearchProvider()
public void initialize(Engine engine, java.util.Properties props) throws NoRequiredPropertyException, java.io.IOException
initialize in interface WikiProviderNoRequiredPropertyExceptionjava.io.IOExceptionprotected void doFullLuceneReindex() throws java.io.IOException
java.io.IOException - If there's a problem during indexingprotected java.lang.String getAttachmentContent(java.lang.String attachmentName, int version)
attachmentName - Name of the attachment.version - The version of the attachment.protected java.lang.String getAttachmentContent(Attachment att)
att - Attachment to get content for. Filename extension is used to determine the type of the attachment.protected void updateLuceneIndex(Page page, java.lang.String text)
page - The WikiPage to checktext - The page text to index.protected org.apache.lucene.document.Document luceneIndexPage(Page page, java.lang.String text, org.apache.lucene.index.IndexWriter writer) throws java.io.IOException
page - WikiPagetext - Page text to indexwriter - The Lucene IndexWriter to use for indexingjava.io.IOException - If there's an indexing problempublic void pageRemoved(Page page)
pageRemoved in interface SearchProviderpage - Page to remove from search index.public void reindexPage(Page page)
reindexPage in interface SearchProviderpage - WikiPage to add to the update queue.public java.util.Collection<SearchResult> findPages(java.lang.String query, Context wikiContext) throws ProviderException
findPages in interface SearchProviderquery - query to search forwikiContext - the context within which to run the searchProviderException - if the search provider failed.public java.util.Collection<SearchResult> findPages(java.lang.String query, int flags, Context wikiContext) throws ProviderException
query - The query to perform in Lucene query languageflags - A set of flagsProviderException - if there is a problem with the backendpublic java.lang.String getProviderInfo()
getProviderInfo in interface WikiProviderCopyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.