Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build against Lucene 9 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>2.0</version>

<properties>
<solr.version>8.2.0</solr.version>
<icu.version>62.1</icu.version>
<solr.version>9.0.0</solr.version>
<icu.version>68.2</icu.version>
</properties>


Expand All @@ -31,7 +31,7 @@

<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-icu</artifactId>
<artifactId>lucene-analysis-icu</artifactId>
<version>${solr.version}</version>
<scope>compile</scope>
</dependency>
Expand All @@ -52,15 +52,15 @@

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
<scope>test</scope>
<artifactId>slf4j-api</artifactId>
<version>1.7.28</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
<version>1.7.28</version>
</dependency>
</dependencies>

Expand All @@ -74,8 +74,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion src/java/edu/umich/lib/converters/ISBNNormalizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static String isbn10_to_13(String isbn10) {

int[] digits = new int[12];
for (int i = 0; i < 12; i++) {
digits[i] = new Integer(longisbn.substring(i, i + 1));
digits[i] = Integer.valueOf(longisbn.substring(i, i + 1));
}

Integer sum = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class LCCallNumberNormalizer {

public static final Long MINNUM = new Long(Long.MIN_VALUE);
public static final Long MINNUM = Long.MIN_VALUE;
public static final String JOIN = "";
public static final String TOPALPHA = "@@@@";
public static final String TOPSPACES = "@@@@@@@@@@";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package edu.umich.lib.solr_filters;

import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;
import org.apache.lucene.analysis.TokenStream;
import edu.umich.lib.solr_filters.AnchoredSearchFilter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.umich.lib.solr_filters;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUFoldingFilterFactory;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.AbstractAnalysisFactory;
import java.util.Map;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.umich.lib.solr_filters;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package edu.umich.lib.solr_filters;
import java.util.Map;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;
import org.apache.lucene.analysis.TokenStream;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.umich.lib.solr_filters;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;

import java.util.Map;

Expand Down
58 changes: 58 additions & 0 deletions src/java/edu/umich/lib/solr_filters/LeftAnchoredSearchFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package edu.umich.lib.solr_filters;

import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class LeftAnchoredSearchFilter extends TokenFilter {

private Integer current_position = 0;
private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
private final CharTermAttribute myTermAttribute = addAttribute(CharTermAttribute.class);
private final OffsetAttribute offsetAttr = addAttribute(OffsetAttribute.class);
private final PositionLengthAttribute posLengthAttr = addAttribute(PositionLengthAttribute.class);

protected LeftAnchoredSearchFilter(TokenStream input) {
super(input);
}



private void reset_class_variables() {
current_position = 0;
}

/**
* Takes a set of tokens and returns them with their position appended
* to the term (so [bill, dueber] becomes [bill1, dueber2]. When used
* with a phrase query, will only allow matches that are left-anchored
* <p>
* We deal with the positionIncrementAttribute so tokens that occupy
* the same position ([[Bill,bill], [Dueber,dueber]) will have the
* correct number appended.
*
* @return boolean
* @throws IOException
*/
@Override
public final boolean incrementToken() throws IOException {
if (!input.incrementToken()) {
reset_class_variables();
return false;
}

String t = myTermAttribute.toString();
current_position += posIncrAtt.getPositionIncrement();

String newtok = t + current_position.toString();
myTermAttribute.setEmpty().append(newtok);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.umich.lib.solr_filters;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;

import java.util.Map;

Expand Down