diff --git a/src/include/zvec/core/framework/index_document.h b/src/include/zvec/core/framework/index_document.h index aa74e606..b3dc5826 100644 --- a/src/include/zvec/core/framework/index_document.h +++ b/src/include/zvec/core/framework/index_document.h @@ -248,14 +248,16 @@ class IndexDocumentHeap : public ailego::Heap { //! Insert a document into the heap void emplace(uint64_t key, float score) { - if (score <= threshold_) { + if (score <= threshold_ && + (!this->full() || score < this->front().score())) { ailego::Heap::emplace(key, score); } } //! Insert a document into the heap void emplace(uint64_t key, float score, uint32_t index) { - if (score <= threshold_) { + if (score <= threshold_ && + (!this->full() || score < this->front().score())) { ailego::Heap::emplace(key, score, index); } }