Extensions Wiki » Extensions » Lucene Plugin

Lucene Plugin

Last modified by Vincent Massol on 2013/03/11 09:39
cogIndexes a wiki's documents using Lucene, in an asynchronous manner
TypePlugin
Developed by

XWiki Development Team

LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise, XWiki Enterprise Manager, XWiki Watch

Download

Description

It can be used in place of the default search implementation which uses Hibernate to search for documents.

Installation

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.

Example

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

Result

Nb found: 1

  • Web Home : 0.18571019

Prerequisites & Installation Instructions

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>.

Tags:
Created by VincentMassol on 2007/03/09 17:17

Download XWiki