From 7e8bb5a35d5d0e2ada24ddc0c9a250862af2f210 Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Tue, 31 Oct 2017 09:43:41 +0100 Subject: [PATCH] make changes to adapt to new Lucene 7.0.0 design Change-Id: I1053765276f25368023a499dd0e52556d94d62ce Signed-off-by: Florent BENOIT --- .../api/vfs/search/impl/LuceneSearcher.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/search/impl/LuceneSearcher.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/search/impl/LuceneSearcher.java index f0af21abb1cc..4bd78a63082d 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/search/impl/LuceneSearcher.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/search/impl/LuceneSearcher.java @@ -25,9 +25,9 @@ import java.util.concurrent.ExecutorService; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.core.LowerCaseFilter; -import org.apache.lucene.analysis.core.WhitespaceTokenizer; +import org.apache.lucene.analysis.core.LowerCaseFilterFactory; +import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory; +import org.apache.lucene.analysis.custom.CustomAnalyzer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; import org.apache.lucene.document.Document; @@ -121,15 +121,11 @@ public boolean removeIndexFilter(VirtualFileFilter indexFilter) { return excludeFileIndexFilters.remove(indexFilter); } - protected Analyzer makeAnalyzer() { - return new Analyzer() { - @Override - protected TokenStreamComponents createComponents(String fieldName) { - Tokenizer tokenizer = new WhitespaceTokenizer(); - TokenStream filter = new LowerCaseFilter(tokenizer); - return new TokenStreamComponents(tokenizer, filter); - } - }; + protected Analyzer makeAnalyzer() throws IOException { + return CustomAnalyzer.builder() + .withTokenizer(WhitespaceTokenizerFactory.class) + .addTokenFilter(LowerCaseFilterFactory.class) + .build(); } protected abstract Directory makeDirectory() throws ServerException; @@ -319,7 +315,7 @@ public SearchResult search(QueryExpression query) throws ServerException { } } - private Query createLuceneQuery(QueryExpression query) throws ParseException { + private Query createLuceneQuery(QueryExpression query) throws ParseException, IOException { BooleanQuery.Builder luceneQueryBuilder = new BooleanQuery.Builder(); final String name = query.getName(); final String path = query.getPath();