 | Indexes a wiki's documents using Lucene, in an asynchronous manner |
| Bundled With | XWiki Enterprise, XWiki Enterprise Manager, XWiki Watch |
Download
It can be used in place of the default search implementation which uses Hibernate to search for documents.
Activate the plugin by editing your WEB-INF/xwiki.cfg file as follows and restart your XWiki instance:
xwiki.plugins=[...],com.xpn.xwiki.plugin.lucene.LucenePlugin
xwiki.plugins.lucene.indexdir=/tmp/xwiki/lucene
xwiki.plugins.lucene.analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
xwiki.plugins.lucene.indexinterval=20
Where:
- The indexdir property points to where Lucene will generate the index file.
- The analyzer property is the default Lucene Analyzer which converts all words in lowercase and filters out simple words such as "the", "a", etc. You can specify any Analyzer you wish to use here.
- The indexinterval property controls how frequently the plugin starts an indexation thread (the value is in seconds).
To use the plugin in your wiki, you'll need to write some Velocity code to integrate it where you want to use it, as shown below.
Here's some code that does a search on "keyword" and lists all the results found:
#set($results = $xwiki.lucene.getSearchResults("keyword", "default,en,fr"))
Nb found: $results.hitcount
#foreach($result in $results.results)
* [${result.web}.${result.name}] #if($result.filename)($result.filename)\#end : $result.score
#end
Nb found: 1
Follow these steps:
- Add the JAR in your container classpath (WEB-INF/lib)
- Edit xwiki.cfg and add the following line to the list of plugins :
xwiki.plugins=\
[...]
... ,\
<plugin package>
- Restart your container
- Verify the plugin is properly installed by typing the following in a wiki page :
{{velocity}}
$xwiki.<plugin name>.name
{{/velocity}}
If the installation has been successful, you will see <plugin name>.