From e14afaf897673f3ead75de347b98b7df0decbcb6 Mon Sep 17 00:00:00 2001 From: Aurelien FOUCRET Date: Mon, 14 Oct 2024 09:21:08 +0200 Subject: [PATCH] Remove useless check. --- .../elasticsearch/script/ScriptTermStats.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/script/ScriptTermStats.java b/server/src/main/java/org/elasticsearch/script/ScriptTermStats.java index d64837fecfa48..b27019765e33b 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptTermStats.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptTermStats.java @@ -70,18 +70,15 @@ public int uniqueTermsCount() { public int matchedTermsCount() { final int docId = docIdSupplier.getAsInt(); int matchedTerms = 0; + advancePostings(docId); - try { - advancePostings(docId); - for (PostingsEnum postingsEnum : postingsSupplier.get()) { - if (postingsEnum != null && postingsEnum.docID() == docId && postingsEnum.freq() > 0) { - matchedTerms++; - } + for (PostingsEnum postingsEnum : postingsSupplier.get()) { + if (postingsEnum != null && postingsEnum.docID() == docId) { + matchedTerms++; } - return matchedTerms; - } catch (IOException e) { - throw new UncheckedIOException(e); } + + return matchedTerms; } /** @@ -176,7 +173,6 @@ public StatsSummary termPositions() { try { advancePostings(docId); - for (PostingsEnum postingsEnum : postingsSupplier.get()) { if (postingsEnum == null || postingsEnum.docID() != docId) { continue;