From 32844e0f3d9cad3bcbcd645bbca5ec5fa635f17e Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Sun, 16 Jun 2024 12:29:27 +0300 Subject: [PATCH] chore: add parsing support for the rest of VECTOR parameters (#3179) --- src/core/search/indices.cc | 9 ++++++--- src/core/search/search.h | 2 +- src/server/search/search_family.cc | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/core/search/indices.cc b/src/core/search/indices.cc index 13d28048431b..9573f2c037cc 100644 --- a/src/core/search/indices.cc +++ b/src/core/search/indices.cc @@ -196,9 +196,12 @@ const float* FlatVectorIndex::Get(DocId doc) const { struct HnswlibAdapter { HnswlibAdapter(const SchemaField::VectorParams& params) - : space_{MakeSpace(params.dim, params.sim)}, world_{GetSpacePtr(), params.capacity, - params.hnsw_m, 200, - 100, true} { + : space_{MakeSpace(params.dim, params.sim)}, world_{GetSpacePtr(), + params.capacity, + params.hnsw_m, + params.hnsw_ef_construction, + 100 /* seed*/, + true} { } void Add(float* data, DocId id) { diff --git a/src/core/search/search.h b/src/core/search/search.h index 4a84831eb915..5e8b14c949a5 100644 --- a/src/core/search/search.h +++ b/src/core/search/search.h @@ -32,7 +32,7 @@ struct SchemaField { size_t dim = 0u; // dimension of knn vectors VectorSimilarity sim = VectorSimilarity::L2; // similarity type size_t capacity = 1000; // initial capacity - + size_t hnsw_ef_construction = 200; size_t hnsw_m = 16; }; diff --git a/src/server/search/search_family.cc b/src/server/search/search_family.cc index 2104226d3e16..95331ce3335c 100644 --- a/src/server/search/search_family.cc +++ b/src/server/search/search_family.cc @@ -74,6 +74,23 @@ search::SchemaField::VectorParams ParseVectorParams(CmdArgParser* parser) { continue; } + if (parser->Check("EF_CONSTRUCTION").ExpectTail(1)) { + params.hnsw_ef_construction = parser->Next(); + continue; + } + + if (parser->Check("EF_RUNTIME").ExpectTail(1)) { + parser->Next(); + LOG(WARNING) << "EF_RUNTIME not supported"; + continue; + } + + if (parser->Check("EPSILON").ExpectTail(1)) { + parser->Next(); + LOG(WARNING) << "EPSILON not supported"; + continue; + } + parser->Skip(2); }