diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexBinaryIDMAP.cpp b/core/src/index/knowhere/knowhere/index/vector_index/IndexBinaryIDMAP.cpp index 5a3ad0a5a7..d368a06ac9 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexBinaryIDMAP.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexBinaryIDMAP.cpp @@ -144,7 +144,7 @@ void BinaryIDMAP::Train(const DatasetPtr& dataset_ptr, const Config& config) { // users will assign the metric type when querying // so we let Tanimoto be the default type - faiss::MetricType metric_type = faiss::METRIC_Tanimoto; + constexpr faiss::MetricType metric_type = faiss::METRIC_Tanimoto; const char* desc = "BFlat"; int64_t dim = config[meta::DIM].get(); @@ -217,7 +217,8 @@ void BinaryIDMAP::QueryImpl(int64_t n, const uint8_t* data, int64_t k, float* distances, int64_t* labels, const Config& config) { // assign the metric type - index_->metric_type = GetMetricType(config[Metric::TYPE].get()); + auto bin_flat_index = dynamic_cast(index_.get())->index; + bin_flat_index->metric_type = GetMetricType(config[Metric::TYPE].get()); int32_t* pdistances = (int32_t*)distances; index_->search(n, (uint8_t*)data, k, pdistances, labels, bitset_); diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexIDMAP.cpp b/core/src/index/knowhere/knowhere/index/vector_index/IndexIDMAP.cpp index 0bf5178d06..7db00b0e69 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexIDMAP.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexIDMAP.cpp @@ -56,7 +56,7 @@ void IDMAP::Train(const DatasetPtr& dataset_ptr, const Config& config) { // users will assign the metric type when querying // so we let L2 be the default type - faiss::MetricType metric_type = faiss::METRIC_L2; + constexpr faiss::MetricType metric_type = faiss::METRIC_L2; const char* desc = "IDMap,Flat"; int64_t dim = config[meta::DIM].get(); @@ -225,7 +225,8 @@ IDMAP::GetVectorById(const DatasetPtr& dataset_ptr, const Config& config) { void IDMAP::QueryImpl(int64_t n, const float* data, int64_t k, float* distances, int64_t* labels, const Config& config) { // assign the metric type - index_->metric_type = GetMetricType(config[Metric::TYPE].get()); + auto flat_index = dynamic_cast(index_.get())->index; + flat_index->metric_type = GetMetricType(config[Metric::TYPE].get()); index_->search(n, (float*)data, k, distances, labels, bitset_); }