From dc932e85e20b24a57f7f6a22302e41ff8195bef9 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Tue, 6 Aug 2024 15:52:09 +0900 Subject: [PATCH] fix: update for migrating lucene 8.11.3 Signed-off-by: Hiroshi Miura --- .../org/languagetool/dev/HomophoneOccurrenceDumper.java | 6 ++---- .../src/main/java/org/languagetool/dev/index/Searcher.java | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/languagetool-standalone/src/main/java/org/languagetool/dev/HomophoneOccurrenceDumper.java b/languagetool-standalone/src/main/java/org/languagetool/dev/HomophoneOccurrenceDumper.java index 2b4d22c4c6841..3fa2ff50743a4 100644 --- a/languagetool-standalone/src/main/java/org/languagetool/dev/HomophoneOccurrenceDumper.java +++ b/languagetool-standalone/src/main/java/org/languagetool/dev/HomophoneOccurrenceDumper.java @@ -18,8 +18,7 @@ */ package org.languagetool.dev; -import org.apache.lucene.index.Fields; -import org.apache.lucene.index.MultiFields; +import org.apache.lucene.index.MultiTerms; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.BytesRef; @@ -112,8 +111,7 @@ private void dumpOccurrences(Set tokens) throws IOException { private TermsEnum getIterator() throws IOException { LuceneSearcher luceneSearcher = getLuceneSearcher(3); - Fields fields = MultiFields.getFields(luceneSearcher.getReader()); - Terms terms = fields.terms("ngram"); + Terms terms = MultiTerms.getTerms(luceneSearcher.getReader(), "ngram"); return terms.iterator(); } diff --git a/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java b/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java index 8564e197a4466..8bc871e3cd571 100644 --- a/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java +++ b/languagetool-wikipedia/src/main/java/org/languagetool/dev/index/Searcher.java @@ -201,7 +201,7 @@ public SearcherResult findRuleMatchesOnIndex(PatternRule rule, Language language } private PossiblyLimitedTopDocs getTopDocs(Query query) throws IOException { - TopScoreDocCollector topCollector = TopScoreDocCollector.create(maxHits); + TopScoreDocCollector topCollector = TopScoreDocCollector.create(maxHits, Integer.MAX_VALUE); Counter clock = Counter.newCounter(true); int waitMillis = 1000; // TODO: if we interrupt the whole thread anyway, do we still need the TimeLimitingCollector?