Skip to content

Commit

Permalink
Upgraded to Lucene 9; updated dependencies; and applied spotless
Browse files Browse the repository at this point in the history
cavorite committed May 25, 2024
1 parent fce3b8b commit 5388f71
Showing 63 changed files with 2,951 additions and 2,713 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -8,4 +8,8 @@ my-idx
.project
.sdkmanrc
.settings
dependency-reduced-pom.xml
.mvn/wrapper
mvnw
mvnw.cmd
tmp
dependency-reduced-pom.xml
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,28 +13,27 @@ Another important feature for Clue is the ability to interact with other Unix co

## About this fork

This is a fork from the upstream version: [javasoze/clue](https://github.com/javasoze/clue/). It's built for Lucene 8
and requires Java 8 (instead of Java 11, which is needed for newer versions of Lucene).
This is a fork from the upstream version: [javasoze/clue](https://github.com/javasoze/clue/). It tracks the two main releases of Lucene in different
branches:

- `main`: For the latest version (9.X). It requires JDK 11 or newer.
- `branch_8X`: For the 8.X release. It requires JDK 8.

### License

Clue is under the [Apache Public License v2.0](http//www.apache.org/licenses/LICENSE-2.0.html).
Clue is under the [Apache Public License v2.0](http://www.apache.org/licenses/LICENSE-2.0.html).

### Bugs

Please file bugs and feature requests [here](https://github.com/javasoze/clue/issues).

## Downloads

latest version: java8-8.11.2-1.0.0

### What's new in this release?

See [Release Note](https://github.com/cavorite/clue/releases/tag/release-java8-8.11.2-1.0.0)
latest version: 9.10.0-1.0.0

## Build

mvn package
./mvnw package

This will create the following artifact in the target directory:

@@ -69,15 +68,14 @@ Command list:
export - export index to readable text files
help - displays help
info - displays information about the index, <segment number> to get information on the segment
merge - force merges segments into given N segments, input: number of max segments
norm - displays norm values for a field for a list of documents
postings - iterating postings given a term, e.g. <fieldname:fieldvalue>
readonly - puts clue in readonly mode
reconstruct - reconstructs an indexed field for a document
search - executes a query against the index, input: <query string>
stored - displays stored data for a given field
showcommitdata - Shows user commit data
terms - gets terms from the index, <field:term>, term can be a prefix
trim - trims the index, <TRIM PERCENTAGE> <OPTIONS>, options are: head, tail, random
tv - shows term vector of a field for a doc

## Build a sample index to play with
@@ -98,34 +96,34 @@ Clue bundles with some test data (15000 car data) for you to build a sample inde

``./bin/clue.sh my-idx terms color_indexed | grep r``

4. Do a search:
3. Do a search:

``./bin/clue.sh my-idx search myquery``

5. Get the index info:
4. Get the index info:

``./bin/clue.sh my-idx info``

6. Iterate a posting for the term color_indexed:red
5. Iterate a posting for the term color_indexed:red

``./bin/clue.sh my-idx postings color_indexed:red``

7. List docvalues for the column-stride-field color:
6. List docvalues for the column-stride-field color:

``./bin/clue.sh my-idx docval color``

8. Get docvalue for the column-stride-field *category* for document 4:
7. Get docvalue for the column-stride-field *category* for document 4:

``./bin/clue.sh my-idx docval *category* 5``

9. Get docvalue for the column-stride-field *year* of type numeric for document 3:
8. Get docvalue for the column-stride-field *year* of type numeric for document 3:

``./bin/clue.sh my-idx docval year 3``

10. Get docvalue for the column-stride-field *json* of type binary for document 3:
9. Get docvalue for the column-stride-field *json* of type binary for document 3:

``./bin/clue.sh my-idx docval json 3``
``./bin/clue.sh my-idx docval json 3``

11. Get docvalue for the column-stride-field *tags* of type sorted-set for document 3:
10. Get docvalue for the column-stride-field *tags* of type sorted-set for document 3:

``./bin/clue.sh my-idx docval tags 3``
134 changes: 84 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<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>io.dashbase.clue</groupId>
<artifactId>clue</artifactId>
<packaging>jar</packaging>
<name>clue</name>
<version>java8-8.11.2-1.0.0</version>
<version>9.10.0-1.0.0</version>
<description>command line client for Apache Lucene</description>

<url>http://github.com/javasoze/clue</url>

<url>http://github.com/cavorite/clue</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
@@ -41,26 +38,57 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>io.dashbase.clue.ClueApplication</mainClass>
<lucene.version>8.11.2</lucene.version>
<dropwizard.version>1.3.5</dropwizard.version>
<retrofit2.version>2.5.0</retrofit2.version>
<lucene.version>9.10.0</lucene.version>
<dropwizard.version>2.1.10</dropwizard.version>
<retrofit2.version>2.9.0</retrofit2.version>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.5.4</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<version>3.13.0</version>
<configuration>
<source>8</source>
<target>8</target>
<release>21</release>
<source>21</source>
<target>21</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<version>3.6.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
@@ -77,15 +105,41 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-wrapper-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.19.1</version>
<style>AOSP</style>
<formatJavadoc>false</formatJavadoc>
</googleJavaFormat>
</java>
<markdown>
<includes>
<include>*.md</include>
</includes>
</markdown>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.16.2</version>
<configuration>
<excludes>
<exclude>org.apache.lucene</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<extensions>
<!-- Enabling the use of FTP -->
<extension>
<groupId>org.kuali.maven.wagons</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.2.1</version>
</extension>
</extensions>
</build>

<dependencyManagement>
@@ -118,22 +172,22 @@
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<artifactId>lucene-analysis-common</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<artifactId>lucene-queries</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-facet</artifactId>
<artifactId>lucene-queryparser</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<artifactId>lucene-facet</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
@@ -155,36 +209,16 @@
<artifactId>converter-jackson</artifactId>
<version>${retrofit2.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>2.12</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
<version>2.14.6</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
</dependencies>

@@ -210,7 +244,7 @@
<repository>
<id>github</id>
<name>clue</name>
<url>https://maven.pkg.github.com/javasoze/clue</url>
<url>https://maven.pkg.github.com/cavorite/clue</url>
</repository>
</distributionManagement>
</project>
35 changes: 29 additions & 6 deletions src/main/java/io/dashbase/clue/ClueAppConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
package io.dashbase.clue;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import io.dashbase.clue.api.*;
import io.dashbase.clue.commands.CommandRegistrar;
import io.dashbase.clue.commands.DefaultCommandRegistrar;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class ClueAppConfiguration {
/**
* Groups the configuration options for the application.
* <p>
* The settings can be overridden through the Yaml configuration file. See 'test_config.yml'
* for an example.
*/
public class ClueAppConfiguration {
public QueryBuilder queryBuilder = new DefaultQueryBuilder();
public DirectoryBuilder dirBuilder = new DefaultDirectoryBuilder();
public IndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory();
public AnalyzerFactory analyzerFactory = new DefaultAnalyzerFactory();
public CommandRegistrar commandRegistrar = new DefaultCommandRegistrar();

private static final String CLUE_CONF_FILE = "clue.yml";
private static final ObjectMapper MAPPER = new ObjectMapper(new YAMLFactory());
static final ObjectMapper MAPPER = createObjectMapper();

private static ObjectMapper createObjectMapper() {

ObjectMapper mapper = new ObjectMapper(new YAMLFactory());

mapper.registerModule(new ParameterNamesModule());
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

return mapper;
}

public static ClueAppConfiguration load() throws IOException {
String confDirPath = System.getProperty("config.dir");
@@ -29,13 +48,17 @@ public static ClueAppConfiguration load() throws IOException {
if (confFile.exists() && confFile.isFile()) {

System.out.println("using configuration file found at: " + confFile.getAbsolutePath());
try (FileReader freader = new FileReader(confFile)) {
return MAPPER.readValue(freader, ClueAppConfiguration.class);
}
return load(confFile);
} else {
// use default
System.out.println("no configuration found, using default configuration");
return new ClueAppConfiguration();
}
}

static ClueAppConfiguration load(File confFile) throws IOException {
try (FileReader reader = new FileReader(confFile)) {
return MAPPER.readValue(reader, ClueAppConfiguration.class);
}
}
}
Loading

0 comments on commit 5388f71

Please sign in to comment.