diff --git a/internal/core/src/segcore/InsertRecord.h b/internal/core/src/segcore/InsertRecord.h index 7da03c1828b36..3f9171f2feba1 100644 --- a/internal/core/src/segcore/InsertRecord.h +++ b/internal/core/src/segcore/InsertRecord.h @@ -258,6 +258,7 @@ class OffsetOrderedArray : public OffsetMap { if (!false_filtered_out) { cnt = size - bitset.count(); } + auto more_hit_than_limit = cnt > limit; limit = std::min(limit, cnt); std::vector seg_offsets; seg_offsets.reserve(limit); @@ -274,7 +275,7 @@ class OffsetOrderedArray : public OffsetMap { hit_num++; } } - return {seg_offsets, it != array_.end()}; + return {seg_offsets, more_hit_than_limit && it != array_.end()}; } void diff --git a/internal/core/unittest/test_offset_ordered_array.cpp b/internal/core/unittest/test_offset_ordered_array.cpp index 1eb2e272b0f8f..fd817fbdd5b92 100644 --- a/internal/core/unittest/test_offset_ordered_array.cpp +++ b/internal/core/unittest/test_offset_ordered_array.cpp @@ -130,10 +130,10 @@ TYPED_TEST_P(TypedOffsetOrderedArrayTest, find_first) { none.reset(); auto result_pair = this->map_.find_first(num / 2, none, true); ASSERT_EQ(0, result_pair.first.size()); - ASSERT_TRUE(result_pair.second); + ASSERT_FALSE(result_pair.second); result_pair = this->map_.find_first(NoLimit, none, true); ASSERT_EQ(0, result_pair.first.size()); - ASSERT_TRUE(result_pair.second); + ASSERT_FALSE(result_pair.second); } }