From b780ac5cecde071cdaedad44b4c37d8a53409c22 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 19 Dec 2024 08:56:38 -0500 Subject: [PATCH] Fix MissingValues ordinal traversal and MultiOrdinalsTests tests Signed-off-by: Andriy Redko --- .../opensearch/search/aggregations/support/MissingValues.java | 2 ++ .../opensearch/index/fielddata/ordinals/MultiOrdinalsTests.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/aggregations/support/MissingValues.java b/server/src/main/java/org/opensearch/search/aggregations/support/MissingValues.java index 1a17fc4bcd298..a5c685a0930e2 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/support/MissingValues.java +++ b/server/src/main/java/org/opensearch/search/aggregations/support/MissingValues.java @@ -368,6 +368,8 @@ public long nextOrd() throws IOException { final long ord = values.nextOrd(); if (ord < insertedOrd) { return ord; + } else if (ord == SortedSetDocValues.NO_MORE_DOCS /* no more docs */) { + return SortedSetDocValues.NO_MORE_DOCS; } else { return ord + 1; } diff --git a/server/src/test/java/org/opensearch/index/fielddata/ordinals/MultiOrdinalsTests.java b/server/src/test/java/org/opensearch/index/fielddata/ordinals/MultiOrdinalsTests.java index 264536c4bb7fb..64cb953a27cf3 100644 --- a/server/src/test/java/org/opensearch/index/fielddata/ordinals/MultiOrdinalsTests.java +++ b/server/src/test/java/org/opensearch/index/fielddata/ordinals/MultiOrdinalsTests.java @@ -280,7 +280,7 @@ private void assertEquals(SortedSetDocValues docs, long[][] ordinalPlan) throws for (long ord : ords) { assertThat(docs.nextOrd(), equalTo(ord)); } - assertThat(docs.nextOrd(), equalTo(SortedSetDocValues.NO_MORE_DOCS)); + assertThat(docs.nextOrd(), equalTo((long) SortedSetDocValues.NO_MORE_DOCS)); } } }