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

  1. Right click on the root package.

  2. Select moduleJava Architect→creationgroupCreate element→javacomponentJava Component

  3. Name the new component it "lucene-core"

3. Reverse the Lucene library into the component

  1. Right click on the "lucene-core" Component

  2. Select moduleJava Architect→reversegroupReverse→reversebinaryReverse Java application from binaries

  3. In the "Files to reverse" tab,

    1. change the directory to the one that contains the Lucene JARS,

    2. and find "lucene-core-7.3.1.jar".

  4. In the "Granularity" combo, select "Simple structural"

  5. Click, Next, Next, Reverse.

Tip 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

  1. Once finished, let’s update the reverse class path to include the reversed libraries:

    • Right click on the root package

    • Select "moduleJava Architect→configurationgroupConfiguration→editclasspathEdit accessible classes"

      03 edit reverse classpath
    • In the dialog, click on the first button "Add external jar 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 this case repeat steps 1 from 4 for each library to reverse.

Important

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:

  1. lucene-core

  2. lucene-queries

  3. lucene-sandbox

Appendix

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>