From 337cc0756dcad5e84cfac657109d086bdd98a5ff Mon Sep 17 00:00:00 2001 From: Chun Han <116052805+MrPresent-Han@users.noreply.github.com> Date: Sat, 13 Apr 2024 22:13:23 +0800 Subject: [PATCH] fix: lack good results for insufficient ef(#29883) (#32080) related: #29883 Signed-off-by: MrPresent-Han --- internal/core/src/index/VectorDiskIndex.cpp | 5 ++--- internal/core/src/index/VectorDiskIndex.h | 2 +- internal/core/src/index/VectorIndex.h | 2 +- internal/core/src/index/VectorMemIndex.cpp | 5 ++--- internal/core/src/index/VectorMemIndex.h | 2 +- internal/core/src/query/GroupByOperator.h | 7 ++++++- internal/core/unittest/test_indexing.cpp | 3 ++- tests/python_client/testcases/test_search.py | 2 +- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/internal/core/src/index/VectorDiskIndex.cpp b/internal/core/src/index/VectorDiskIndex.cpp index 459b3ef12f..02056e163c 100644 --- a/internal/core/src/index/VectorDiskIndex.cpp +++ b/internal/core/src/index/VectorDiskIndex.cpp @@ -419,10 +419,9 @@ VectorDiskAnnIndex::Query(const DatasetPtr dataset, template knowhere::expected>> VectorDiskAnnIndex::VectorIterators(const DatasetPtr dataset, - const SearchInfo& search_info, + const knowhere::Json& conf, const BitsetView& bitset) const { - return this->index_.AnnIterator( - *dataset, search_info.search_params_, bitset); + return this->index_.AnnIterator(*dataset, conf, bitset); } template diff --git a/internal/core/src/index/VectorDiskIndex.h b/internal/core/src/index/VectorDiskIndex.h index 7f5feca94b..f74576aef7 100644 --- a/internal/core/src/index/VectorDiskIndex.h +++ b/internal/core/src/index/VectorDiskIndex.h @@ -109,7 +109,7 @@ class VectorDiskAnnIndex : public VectorIndex { knowhere::expected< std::vector>> VectorIterators(const DatasetPtr dataset, - const SearchInfo& search_info, + const knowhere::Json& json, const BitsetView& bitset) const override; private: diff --git a/internal/core/src/index/VectorIndex.h b/internal/core/src/index/VectorIndex.h index 03af2647c7..95356b7c20 100644 --- a/internal/core/src/index/VectorIndex.h +++ b/internal/core/src/index/VectorIndex.h @@ -63,7 +63,7 @@ class VectorIndex : public IndexBase { virtual knowhere::expected< std::vector>> VectorIterators(const DatasetPtr dataset, - const SearchInfo& search_info, + const knowhere::Json& json, const BitsetView& bitset) const { throw std::runtime_error("VectorIndex:" + this->GetIndexType() + " didn't implement VectorIterator interface, " diff --git a/internal/core/src/index/VectorMemIndex.cpp b/internal/core/src/index/VectorMemIndex.cpp index 3741b88694..688e7d992c 100644 --- a/internal/core/src/index/VectorMemIndex.cpp +++ b/internal/core/src/index/VectorMemIndex.cpp @@ -150,10 +150,9 @@ VectorMemIndex::UploadV2(const Config& config) { template knowhere::expected>> VectorMemIndex::VectorIterators(const milvus::DatasetPtr dataset, - const milvus::SearchInfo& search_info, + const knowhere::Json& conf, const milvus::BitsetView& bitset) const { - return this->index_.AnnIterator( - *dataset, search_info.search_params_, bitset); + return this->index_.AnnIterator(*dataset, conf, bitset); } template diff --git a/internal/core/src/index/VectorMemIndex.h b/internal/core/src/index/VectorMemIndex.h index cda1f2fc7c..e4e0e36e9e 100644 --- a/internal/core/src/index/VectorMemIndex.h +++ b/internal/core/src/index/VectorMemIndex.h @@ -97,7 +97,7 @@ class VectorMemIndex : public VectorIndex { knowhere::expected< std::vector>> VectorIterators(const DatasetPtr dataset, - const SearchInfo& search_info, + const knowhere::Json& json, const BitsetView& bitset) const override; protected: diff --git a/internal/core/src/query/GroupByOperator.h b/internal/core/src/query/GroupByOperator.h index 988b9cbbd5..86e3356553 100644 --- a/internal/core/src/query/GroupByOperator.h +++ b/internal/core/src/query/GroupByOperator.h @@ -132,10 +132,15 @@ PrepareVectorIteratorsFromIndex(const SearchInfo& search_info, const index::VectorIndex& index) { if (search_info.group_by_field_id_.has_value()) { try { + auto search_conf = search_info.search_params_; + if (search_conf.contains(knowhere::indexparam::EF)) { + search_conf[knowhere::indexparam::SEED_EF] = + search_conf[knowhere::indexparam::EF]; + } knowhere::expected< std::vector>> iterators_val = - index.VectorIterators(dataset, search_info, bitset); + index.VectorIterators(dataset, search_conf, bitset); if (iterators_val.has_value()) { search_result.AssembleChunkVectorIterators( nq, 1, -1, iterators_val.value()); diff --git a/internal/core/unittest/test_indexing.cpp b/internal/core/unittest/test_indexing.cpp index b94c442ead..351c6b922a 100644 --- a/internal/core/unittest/test_indexing.cpp +++ b/internal/core/unittest/test_indexing.cpp @@ -466,7 +466,8 @@ TEST(Indexing, Iterator) { knowhere::expected< std::vector>> - kw_iterators = vec_index->VectorIterators(query_ds, searchInfo, view); + kw_iterators = vec_index->VectorIterators( + query_ds, searchInfo.search_params_, view); ASSERT_TRUE(kw_iterators.has_value()); ASSERT_EQ(kw_iterators.value().size(), 1); auto iterator = kw_iterators.value()[0]; diff --git a/tests/python_client/testcases/test_search.py b/tests/python_client/testcases/test_search.py index bc8cecd44e..cd587c4782 100644 --- a/tests/python_client/testcases/test_search.py +++ b/tests/python_client/testcases/test_search.py @@ -9973,7 +9973,7 @@ class TestSearchIterator(TestcaseBase): class TestSearchGroupBy(TestcaseBase): """ Test case of search group by """ - @pytest.mark.tags(CaseLabel.L0) + @pytest.mark.tags(CaseLabel.L3) @pytest.mark.parametrize("index_type, metric", zip(["FLAT", "IVF_FLAT", "HNSW"], ct.float_metrics)) @pytest.mark.parametrize("vector_data_type", ["FLOAT16_VECTOR", "FLOAT_VECTOR", "BFLOAT16_VECTOR"]) def test_search_group_by_default(self, index_type, metric, vector_data_type):