com.xpn.xwiki.plugin.lucene
Class IndexRebuilder
java.lang.Object
com.xpn.xwiki.util.AbstractXWikiRunnable
com.xpn.xwiki.plugin.lucene.IndexRebuilder
- All Implemented Interfaces:
- java.lang.Runnable
public class IndexRebuilder
- extends com.xpn.xwiki.util.AbstractXWikiRunnable
Handles rebuilding of the whole Lucene Search Index. This involves the following steps:
- empty the existing index
- retrieve the names of all virtual wikis
- foreach document in each virtual wiki:
- index the document
- get and index all translations of the document
- get and index all attachments of the document
- get and index all objects of the document
The rebuild can be triggered using the LucenePluginApi.rebuildIndex() method of the LucenePluginApi.
Once a rebuild request is made, a new thread is created, so the requesting script can continue processing, while the
rebuilding is done in the background. The actual indexing is done by the IndexUpdater thread, this thread just
gathers the data and passes it to the IndexUpdater.
As a summary, this plugin:
- cleans the Lucene search indexes and re-submits all the contents of all the wikis for indexing
- without clogging the indexing thread (since 1.2)
- all in a background thread (since 1.2)
- making sure that only one rebuild is in progress (since 1.2)
- Version:
- $Id: IndexRebuilder.java 33152 2010-11-26 16:49:03Z tmortagne $
|
Method Summary |
protected int |
addTranslationsOfDocument(com.xpn.xwiki.doc.XWikiDocument document,
com.xpn.xwiki.XWikiContext wikiContext)
|
org.apache.lucene.search.Searcher |
createSearcher(org.apache.lucene.store.Directory directory,
com.xpn.xwiki.XWikiContext context)
|
protected int |
indexWiki(java.lang.String wikiName,
com.xpn.xwiki.XWikiContext context)
Adds the content of a given wiki to the indexUpdater's queue. |
boolean |
isIndexed(java.lang.String wikiName,
java.lang.String documentName,
org.apache.lucene.search.Searcher searcher)
|
protected void |
runInternal()
|
int |
startIndex(java.util.Collection<java.lang.String> wikis,
java.lang.String hqlFilter,
boolean clearIndex,
boolean onlyNew,
com.xpn.xwiki.XWikiContext context)
|
int |
startRebuildIndex(com.xpn.xwiki.XWikiContext context)
|
| Methods inherited from class com.xpn.xwiki.util.AbstractXWikiRunnable |
cleanupExecutionContext, initExecutionContext, run |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IndexRebuilder
public IndexRebuilder(IndexUpdater indexUpdater,
com.xpn.xwiki.XWikiContext context)
startRebuildIndex
public int startRebuildIndex(com.xpn.xwiki.XWikiContext context)
startIndex
public int startIndex(java.util.Collection<java.lang.String> wikis,
java.lang.String hqlFilter,
boolean clearIndex,
boolean onlyNew,
com.xpn.xwiki.XWikiContext context)
runInternal
protected void runInternal()
- Specified by:
runInternal in class com.xpn.xwiki.util.AbstractXWikiRunnable
indexWiki
protected int indexWiki(java.lang.String wikiName,
com.xpn.xwiki.XWikiContext context)
- Adds the content of a given wiki to the indexUpdater's queue.
- Parameters:
wikiName - the name of the wiki to indexcontext - the XWiki context
- Returns:
- the number of indexed elements
addTranslationsOfDocument
protected int addTranslationsOfDocument(com.xpn.xwiki.doc.XWikiDocument document,
com.xpn.xwiki.XWikiContext wikiContext)
isIndexed
public boolean isIndexed(java.lang.String wikiName,
java.lang.String documentName,
org.apache.lucene.search.Searcher searcher)
createSearcher
public org.apache.lucene.search.Searcher createSearcher(org.apache.lucene.store.Directory directory,
com.xpn.xwiki.XWikiContext context)
Copyright © 2004-2010 XWiki. All Rights Reserved.