diff --git a/internal/core/src/segcore/ReduceStructure.h b/internal/core/src/segcore/ReduceStructure.h index 96956f006f..48655f2aa7 100644 --- a/internal/core/src/segcore/ReduceStructure.h +++ b/internal/core/src/segcore/ReduceStructure.h @@ -44,7 +44,10 @@ struct SearchResultPair { bool operator>(const SearchResultPair& other) const { - if (std::fabs(distance_ - other.distance_) < 0.000001f) { + //according to FLT_EPSILON in cfloat, 0.000000119 is the maximum flaw for float32 + //we use this to differentiate distances that are too close to each other to maintain the + //stable order for reduce + if (std::fabs(distance_ - other.distance_) < 0.000000119) { return primary_key_ < other.primary_key_; } return distance_ > other.distance_;