Apache LuceneTM is a high-performance, full-featured text search engine library written entirely in Java.
This library is available for download at https://lucene.apache.org/core/downloads.html.
You may want to create a maven project instead. You will find an example in the appendices.
Let’s setup a Java 8 project that uses Apache Lucene:
1. Create a new Modelio project with the Java 8 template.
Follow the Example 1 to create a project.
2. Create a "lucene-core" java component
-
Right click on the root package.
-
Select
Java Architect→
Create element→
Java Component
-
Name the new component it "lucene-core"
3. Reverse the Lucene library into the component
-
Right click on the "lucene-core" Component
-
Select
Java Architect→
Reverse→
Reverse Java application from binaries
-
In the "Files to reverse" tab,
-
change the directory to the one that contains the Lucene JARS,
-
and find "lucene-core-7.3.1.jar".
-
-
In the "Granularity" combo, select "Simple structural"
-
Click, Next, Next, Reverse.
![]() |
For a maven project, you will find the libraries in your maven cache, usually at $(HOME)/.m2/repository/org/apache/lucene
|
4. Update the reverse class path
-
Once finished, let’s update the reverse class path to include the reversed libraries:
-
Right click on the root package
-
Select "
Java Architect→
Configuration→
Edit accessible classes"
-
In the dialog, click on the first button "
Add external jar"
-
In the file browser, find and select the "lucene-core-7.3.1.jar" library .jar file
-
Validate the dialog with the 'OK' button
-
5. Reverse other Lucene JARS
You may want to reverse also other Lucene JARS at the same time.
![]() |
In order to have references fully resolved you need to reverse the JARS in the dependency hierarchy reverse order: the JARS that depend on nobody first. eg: To reverse 'lucene-queryparser' you need to reverse in order:
|
Appendix
References
-
Baeldung tutorial: https://www.baeldung.com/lucene
-
Download page: https://lucene.apache.org/core/downloads.html
Maven example
Here is an example maven pom.xml to use some lucene libraries:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-lucene</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>8.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>8.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>8.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>8.7.0</version>
</dependency>
</dependencies>
</project>