Lucene Search API

Last modified by Admin on 2024/07/05 17:54

cogLucene index management and query
TypeJAR
Category
Developed by

XWiki Development Team

Active Installs27
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

The Lucene module is not really maintained anymore, you should now use the Solr Search API and Solr Search Query API.

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

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

Dependencies

Dependencies for this extension (org.xwiki.platform:xwiki-platform-search-lucene-api 6.4.8):

  • org.xwiki.platform:xwiki-platform-oldcore 6.4.8
  • org.xwiki.platform:xwiki-platform-rest-server 6.4.8
  • org.apache.lucene:lucene-core 4.10.3
  • org.apache.lucene:lucene-queryparser 4.10.3
  • org.apache.lucene:lucene-analyzers-common 4.10.3
  • org.apache.commons:commons-lang3 3.3.2
  • commons-collections:commons-collections 3.2.1
  • org.apache.tika:tika-parsers 1.6
  • org.ow2.asm:asm 4.1
  • org.bouncycastle:bcprov-jdk15on 1.49
  • org.bouncycastle:bcpkix-jdk15on 1.49
  • org.bouncycastle:bcmail-jdk15on 1.49
  • de.l3s.boilerpipe:boilerpipe 1.2.0-xwiki

Get Connected