This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push: new 62e828c CXF-8098 - Update to Lucene 8.x 62e828c is described below commit 62e828c7e74d0dd5d4e337a090344a13501d8aeb Author: Colm O hEigeartaigh <cohei...@apache.org> AuthorDate: Fri Aug 23 16:04:04 2019 +0100 CXF-8098 - Update to Lucene 8.x --- .../src/main/release/samples/jax_rs/search/pom.xml | 2 +- .../java/demo/jaxrs/search/server/Catalog.java | 7 +- parent/pom.xml | 2 +- rt/rs/extensions/search/pom.xml | 3 +- .../ext/search/lucene/LuceneQueryVisitor.java | 85 +++++++++++++++++----- .../search/tika/TikaLuceneContentExtractor.java | 42 +++++++---- .../lucene/AbstractLuceneQueryVisitorTest.java | 29 +++++--- .../lucene/LuceneQueryVisitorAnalyzerFiqlTest.java | 7 -- .../tika/TikaLuceneContentExtractorTest.java | 28 ++++--- .../cxf/systest/jaxrs/extraction/BookCatalog.java | 7 +- 10 files changed, 138 insertions(+), 74 deletions(-) diff --git a/distribution/src/main/release/samples/jax_rs/search/pom.xml b/distribution/src/main/release/samples/jax_rs/search/pom.xml index e91cd9f..831f27d 100644 --- a/distribution/src/main/release/samples/jax_rs/search/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/search/pom.xml @@ -30,7 +30,7 @@ </parent> <properties> <cxf.version>${project.version}</cxf.version> - <cxf.lucene.version>4.9.0</cxf.lucene.version> + <cxf.lucene.version>8.2.0</cxf.lucene.version> </properties> <profiles> <profile> diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java index ad36697..9f610fb 100644 --- a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java +++ b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java @@ -82,7 +82,6 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; import org.apache.tika.parser.Parser; import org.apache.tika.parser.odf.OpenDocumentParser; import org.apache.tika.parser.pdf.PDFParser; @@ -93,7 +92,7 @@ public class Catalog { Arrays.< Parser >asList(new PDFParser(), new OpenDocumentParser()), new LuceneDocumentMetadata()); private final Directory directory = new RAMDirectory(); - private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9); + private final Analyzer analyzer = new StandardAnalyzer(); private final Storage storage; private final LuceneQueryVisitor<SearchBean> visitor; private final ExecutorService executor = Executors.newFixedThreadPool( @@ -270,7 +269,7 @@ public class Catalog { } private IndexWriter getIndexWriter() throws IOException { - return new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_4_9, analyzer)); + return new IndexWriter(directory, new IndexWriterConfig(analyzer)); } private LuceneQueryVisitor< SearchBean > createVisitor() { @@ -290,7 +289,7 @@ public class Catalog { try { return searcher.search(new TermQuery( - new Term(LuceneDocumentMetadata.SOURCE_FIELD, source)), 1).totalHits > 0; + new Term(LuceneDocumentMetadata.SOURCE_FIELD, source)), 1).totalHits.value > 0; } finally { reader.close(); } diff --git a/parent/pom.xml b/parent/pom.xml index 1e35b13..9ffc623 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -159,7 +159,7 @@ <cxf.littleproxy.version>1.1.2</cxf.littleproxy.version> <cxf.log4j.version>1.2.17</cxf.log4j.version> <cxf.logback.classic.version>1.2.3</cxf.logback.classic.version> - <cxf.lucene.version>4.9.0</cxf.lucene.version> + <cxf.lucene.version>8.2.0</cxf.lucene.version> <cxf.maven.core.version>3.6.1</cxf.maven.core.version> <cxf.microprofile.config.version>1.2</cxf.microprofile.config.version> <cxf.microprofile.rest.client.version>1.3.3</cxf.microprofile.rest.client.version> diff --git a/rt/rs/extensions/search/pom.xml b/rt/rs/extensions/search/pom.xml index 44236d3..baa81da 100644 --- a/rt/rs/extensions/search/pom.xml +++ b/rt/rs/extensions/search/pom.xml @@ -34,7 +34,8 @@ <cxf.module.name>org.apache.cxf.rs.search</cxf.module.name> <cxf.osgi.import> javax.persistence*;resolution:=optional, - org.apache.tika.*;resolution:=optional + org.apache.tika.*;resolution:=optional, + org.apache.lucene.*;resolution:=optional </cxf.osgi.import> </properties> <dependencies> diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java index 6589bd0..0d0b1aa 100644 --- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java +++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitor.java @@ -35,10 +35,13 @@ import org.apache.cxf.jaxrs.ext.search.visitor.VisitorState; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools.Resolution; +import org.apache.lucene.document.DoublePoint; +import org.apache.lucene.document.FloatPoint; +import org.apache.lucene.document.IntPoint; +import org.apache.lucene.document.LongPoint; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; @@ -163,9 +166,9 @@ public class LuceneQueryVisitor<T> extends AbstractSearchConditionVisitor<T, Que query = createEqualsQuery(clazz, name, value); break; case NOT_EQUALS: - BooleanQuery booleanQuery = new BooleanQuery(); - booleanQuery.add(createEqualsQuery(clazz, name, value), - BooleanClause.Occur.MUST_NOT); + BooleanQuery.Builder booleanBuilder = new BooleanQuery.Builder(); + booleanBuilder.add(createEqualsQuery(clazz, name, value), BooleanClause.Occur.MUST_NOT); + BooleanQuery booleanQuery = booleanBuilder.build(); query = booleanQuery; break; case GREATER_THAN: @@ -260,33 +263,79 @@ public class LuceneQueryVisitor<T> extends AbstractSearchConditionVisitor<T, Que private Query createIntRangeQuery(final String name, final Object value, final ConditionType type, final boolean minInclusive, final boolean maxInclusive) { final Integer intValue = Integer.valueOf(value.toString()); + Integer min = getMin(type, intValue); + if (min == null) { + min = Integer.MIN_VALUE; + } else if (min != null && !minInclusive) { + min = Math.addExact(min, 1); + } + + Integer max = getMax(type, intValue); + if (max == null) { + max = Integer.MAX_VALUE; + } else if (max != null && !maxInclusive) { + max = Math.addExact(max, -1); + } - return NumericRangeQuery.newIntRange(name, getMin(type, intValue), - getMax(type, intValue), minInclusive, maxInclusive); + return IntPoint.newRangeQuery(name, min, max); } private Query createLongRangeQuery(final String name, final Object value, final ConditionType type, final boolean minInclusive, final boolean maxInclusive) { final Long longValue = Long.valueOf(value.toString()); + Long min = getMin(type, longValue); + if (min == null) { + min = Long.MIN_VALUE; + } else if (min != null && !minInclusive) { + min = Math.addExact(min, 1); + } - return NumericRangeQuery.newLongRange(name, getMin(type, longValue), - getMax(type, longValue), minInclusive, maxInclusive); + Long max = getMax(type, longValue); + if (max == null) { + max = Long.MAX_VALUE; + } else if (max != null && !maxInclusive) { + max = Math.addExact(max, -1); + } + return LongPoint.newRangeQuery(name, min, max); } private Query createDoubleRangeQuery(final String name, final Object value, final ConditionType type, final boolean minInclusive, final boolean maxInclusive) { final Double doubleValue = Double.valueOf(value.toString()); + Double min = getMin(type, doubleValue); + if (min == null) { + min = Double.NEGATIVE_INFINITY; + } else if (min != null && !minInclusive) { + min = Math.nextUp(min); + } - return NumericRangeQuery.newDoubleRange(name, getMin(type, doubleValue), - getMax(type, doubleValue), minInclusive, maxInclusive); + Double max = getMax(type, doubleValue); + if (max == null) { + max = Double.POSITIVE_INFINITY; + } else if (max != null && !maxInclusive) { + max = Math.nextDown(max); + } + return DoublePoint.newRangeQuery(name, min, max); } private Query createFloatRangeQuery(final String name, final Object value, final ConditionType type, final boolean minInclusive, final boolean maxInclusive) { final Float floatValue = Float.valueOf(value.toString()); + Float min = getMin(type, floatValue); + if (min == null) { + min = Float.NEGATIVE_INFINITY; + } else if (min != null && !minInclusive) { + min = Math.nextUp(min); + } + + Float max = getMax(type, floatValue); + if (max == null) { + max = Float.POSITIVE_INFINITY; + } else if (max != null && !maxInclusive) { + max = Math.nextDown(max); + } - return NumericRangeQuery.newFloatRange(name, getMin(type, floatValue), - getMax(type, floatValue), minInclusive, maxInclusive); + return FloatPoint.newRangeQuery(name, min, max); } private< N > N getMax(final ConditionType type, final N value) { @@ -303,13 +352,13 @@ public class LuceneQueryVisitor<T> extends AbstractSearchConditionVisitor<T, Que BooleanClause.Occur clause = orCondition ? BooleanClause.Occur.SHOULD : BooleanClause.Occur.MUST; - BooleanQuery booleanQuery = new BooleanQuery(); + BooleanQuery.Builder builder = new BooleanQuery.Builder(); for (Query query : queries) { - booleanQuery.add(query, clause); + builder.add(query, clause); } - return booleanQuery; + return builder.build(); } private Query newTermQuery(final String field, final String query) { @@ -322,8 +371,8 @@ public class LuceneQueryVisitor<T> extends AbstractSearchConditionVisitor<T, Que return queryBuilder.createPhraseQuery(field, query); } - final PhraseQuery phraseQuery = new PhraseQuery(); - phraseQuery.add(new Term(field, query)); - return phraseQuery; + PhraseQuery.Builder builder = new PhraseQuery.Builder(); + builder.add(new Term(field, query)); + return builder.build(); } } diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractor.java b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractor.java index 21af2e9..4650c53 100644 --- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractor.java +++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractor.java @@ -28,12 +28,13 @@ import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.jaxrs.ext.search.ParamConverterUtils; import org.apache.cxf.jaxrs.ext.search.tika.TikaContentExtractor.TikaContent; import org.apache.lucene.document.Document; -import org.apache.lucene.document.DoubleField; +import org.apache.lucene.document.DoublePoint; import org.apache.lucene.document.Field; import org.apache.lucene.document.Field.Store; -import org.apache.lucene.document.FloatField; -import org.apache.lucene.document.IntField; -import org.apache.lucene.document.LongField; +import org.apache.lucene.document.FloatPoint; +import org.apache.lucene.document.IntPoint; +import org.apache.lucene.document.LongPoint; +import org.apache.lucene.document.StoredField; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.tika.metadata.Metadata; @@ -188,7 +189,7 @@ public class TikaLuceneContentExtractor { if (extractMetadata) { Metadata metadata = content.getMetadata(); for (final String property: metadata.names()) { - document.add(getField(documentMetadata, property, metadata.get(property))); + addField(document, documentMetadata, property, metadata.get(property)); } } @@ -206,7 +207,8 @@ public class TikaLuceneContentExtractor { } - private static Field getField(final LuceneDocumentMetadata documentMetadata, + private static void addField(final Document document, + final LuceneDocumentMetadata documentMetadata, final String name, final String value) { final Class< ? > type = documentMetadata.getFieldType(name); final ParamConverterProvider provider = documentMetadata.getFieldTypeConverter(); @@ -214,18 +216,25 @@ public class TikaLuceneContentExtractor { if (type != null) { if (Number.class.isAssignableFrom(type)) { if (Double.class.isAssignableFrom(type)) { - return new DoubleField(name, - ParamConverterUtils.getValue(Double.class, provider, value), Store.YES); + Double number = ParamConverterUtils.getValue(Double.class, provider, value); + document.add(new DoublePoint(name, number)); + document.add(new StoredField(name, number)); } else if (Float.class.isAssignableFrom(type)) { - return new FloatField(name, - ParamConverterUtils.getValue(Float.class, provider, value), Store.YES); + Float number = ParamConverterUtils.getValue(Float.class, provider, value); + document.add(new FloatPoint(name, number)); + document.add(new StoredField(name, number)); } else if (Long.class.isAssignableFrom(type)) { - return new LongField(name, - ParamConverterUtils.getValue(Long.class, provider, value), Store.YES); + Long number = ParamConverterUtils.getValue(Long.class, provider, value); + document.add(new LongPoint(name, number)); + document.add(new StoredField(name, number)); } else if (Integer.class.isAssignableFrom(type) || Byte.class.isAssignableFrom(type)) { - return new IntField(name, - ParamConverterUtils.getValue(Integer.class, provider, value), Store.YES); + Integer number = ParamConverterUtils.getValue(Integer.class, provider, value); + document.add(new IntPoint(name, number)); + document.add(new StoredField(name, number)); + } else { + document.add(new StringField(name, value, Store.YES)); } + return; } else if (Date.class.isAssignableFrom(type)) { final Date date = ParamConverterUtils.getValue(Date.class, provider, value); Field field = null; @@ -237,10 +246,11 @@ public class TikaLuceneContentExtractor { field = new StringField(name, value, Store.YES); } - return field; + document.add(field); + return; } } - return new StringField(name, value, Store.YES); + document.add(new StringField(name, value, Store.YES)); } } diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java index d40837c..2ae4f1a 100644 --- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java +++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java @@ -18,8 +18,11 @@ */ package org.apache.cxf.jaxrs.ext.search.lucene; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Collections; +import org.apache.commons.io.FileUtils; import org.apache.cxf.jaxrs.ext.search.SearchBean; import org.apache.cxf.jaxrs.ext.search.SearchCondition; import org.apache.cxf.jaxrs.ext.search.SearchConditionParser; @@ -28,7 +31,8 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; -import org.apache.lucene.document.IntField; +import org.apache.lucene.document.IntPoint; +import org.apache.lucene.document.StoredField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; @@ -38,8 +42,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; +import org.apache.lucene.store.MMapDirectory; import org.junit.After; import org.junit.Before; @@ -52,19 +55,22 @@ public abstract class AbstractLuceneQueryVisitorTest { private IndexSearcher isearcher; private Directory directory; private Analyzer analyzer; + private Path tempDirectory; @Before public void setUp() throws Exception { - analyzer = new StandardAnalyzer(Version.LUCENE_4_9); - directory = new RAMDirectory(); - IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_9, analyzer); + analyzer = new StandardAnalyzer(); + tempDirectory = Files.createTempDirectory("lucene"); + directory = new MMapDirectory(tempDirectory); + IndexWriterConfig config = new IndexWriterConfig(analyzer); IndexWriter iwriter = new IndexWriter(directory, config); Document doc = new Document(); doc.add(new Field("contents", "name=text", TextField.TYPE_STORED)); - IntField intField = new IntField("intfield", 4, Field.Store.YES); - doc.add(intField); + IntPoint intPoint = new IntPoint("intfield", 4); + doc.add(intPoint); + doc.add(new StoredField("intfield", 4)); iwriter.addDocument(doc); iwriter.close(); @@ -76,6 +82,7 @@ public abstract class AbstractLuceneQueryVisitorTest { public void tearDown() throws Exception { ireader.close(); directory.close(); + FileUtils.deleteQuietly(tempDirectory.toFile()); } protected abstract SearchConditionParser<SearchBean> getParser(); @@ -95,12 +102,12 @@ public abstract class AbstractLuceneQueryVisitorTest { } protected void doTestNoMatch(Query query) throws Exception { - ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs; + ScoreDoc[] hits = isearcher.search(query, 1000).scoreDocs; assertEquals(0, hits.length); } protected void doTestTextContentMatchWithQuery(Query query) throws Exception { - ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs; + ScoreDoc[] hits = isearcher.search(query, 1000).scoreDocs; assertEquals(1, hits.length); // Iterate through the results: for (int i = 0; i < hits.length; i++) { @@ -119,7 +126,7 @@ public abstract class AbstractLuceneQueryVisitorTest { protected void doTestIntContentMatchWithQuery(Query query) throws Exception { - ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs; + ScoreDoc[] hits = isearcher.search(query, 1000).scoreDocs; assertEquals(1, hits.length); // Iterate through the results: for (int i = 0; i < hits.length; i++) { diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitorAnalyzerFiqlTest.java b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitorAnalyzerFiqlTest.java index eb4eb69..029ec61 100644 --- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitorAnalyzerFiqlTest.java +++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/LuceneQueryVisitorAnalyzerFiqlTest.java @@ -25,8 +25,6 @@ import org.apache.lucene.search.Query; import org.junit.Test; -import static org.junit.Assert.assertNull; - public class LuceneQueryVisitorAnalyzerFiqlTest extends AbstractLuceneQueryVisitorTest { @Test public void testTextContentMatchEqual() throws Exception { @@ -34,11 +32,6 @@ public class LuceneQueryVisitorAnalyzerFiqlTest extends AbstractLuceneQueryVisit } @Test - public void testTextContentMatchStopWord() throws Exception { - assertNull("No query should be returned for stop words", createTermQueryWithAnalyzer("ct==the")); - } - - @Test public void testTextAndContentMatch() throws Exception { Query query = createTermQueryWithAnalyzer("contents==namE;contents==tExt"); doTestTextContentMatchWithQuery(query); diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java index 7521e17..f259e4c 100644 --- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java +++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java @@ -19,10 +19,13 @@ package org.apache.cxf.jaxrs.ext.search.tika; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.apache.commons.io.FileUtils; import org.apache.cxf.jaxrs.ext.search.SearchBean; import org.apache.cxf.jaxrs.ext.search.SearchConditionParser; import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser; @@ -37,8 +40,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; +import org.apache.lucene.store.MMapDirectory; import org.apache.tika.parser.pdf.PDFParser; import org.junit.After; @@ -53,13 +55,15 @@ public class TikaLuceneContentExtractorTest { private Directory directory; private IndexWriter writer; private SearchConditionParser< SearchBean > parser; + private Path tempDirectory; @Before public void setUp() throws Exception { - final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9); - directory = new RAMDirectory(); + final Analyzer analyzer = new StandardAnalyzer(); + tempDirectory = Files.createTempDirectory("lucene"); + directory = new MMapDirectory(tempDirectory); - IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_9, analyzer); + IndexWriterConfig config = new IndexWriterConfig(analyzer); writer = new IndexWriter(directory, config); writer.commit(); @@ -67,6 +71,13 @@ public class TikaLuceneContentExtractorTest { extractor = new TikaLuceneContentExtractor(new PDFParser()); } + @After + public void tearDown() throws Exception { + writer.close(); + directory.close(); + FileUtils.deleteQuietly(tempDirectory.toFile()); + } + @Test public void testExtractedTextContentMatchesSearchCriteria() throws Exception { final Document document = extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf")); @@ -229,16 +240,11 @@ public class TikaLuceneContentExtractorTest { visitor.setPrimitiveFieldTypeMap(fieldTypes); visitor.visit(parser.parse(expression)); - ScoreDoc[] hits = searcher.search(visitor.getQuery(), null, 1000).scoreDocs; + ScoreDoc[] hits = searcher.search(visitor.getQuery(), 1000).scoreDocs; assertNotNull(hits); return hits; } } - @After - public void tearDown() throws Exception { - writer.close(); - directory.close(); - } } \ No newline at end of file diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java index e36bbcc..14124d9 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java @@ -56,14 +56,13 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; import org.apache.tika.parser.pdf.PDFParser; @Path("/catalog") public class BookCatalog { private final TikaLuceneContentExtractor extractor = new TikaLuceneContentExtractor(new PDFParser()); private final Directory directory = new RAMDirectory(); - private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9); + private final Analyzer analyzer = new StandardAnalyzer(); private final LuceneQueryVisitor<SearchBean> visitor = createVisitor(); @POST @@ -97,7 +96,7 @@ public class BookCatalog { try (IndexReader reader = DirectoryReader.open(directory)) { IndexSearcher searcher = new IndexSearcher(reader); visitor.visit(searchContext.getCondition(SearchBean.class)); - return Arrays.asList(searcher.search(visitor.getQuery(), null, 1000).scoreDocs); + return Arrays.asList(searcher.search(visitor.getQuery(), 1000).scoreDocs); } } @@ -112,7 +111,7 @@ public class BookCatalog { } private IndexWriter getIndexWriter() throws IOException { - return new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_4_9, analyzer)); + return new IndexWriter(directory, new IndexWriterConfig(analyzer)); } private static LuceneQueryVisitor< SearchBean > createVisitor() {