From c85f4c5695fd09c00febcc9995ea229891ee66d5 Mon Sep 17 00:00:00 2001 From: Aditi Ahuja <48997495+metonymic-smokey@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:38:31 +0530 Subject: [PATCH] MB-64360 - Guardrail fix for missing vectors (#282) In case a doc has invalid vector fields but valid non-vector fields, filter hit IDs may be ineligible for the kNN since the document does not have any/valid vectors. This PR adds a check to avoid kNN in such cases. --- faiss_vector_posting.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/faiss_vector_posting.go b/faiss_vector_posting.go index 6b9840f..9c53c07 100644 --- a/faiss_vector_posting.go +++ b/faiss_vector_posting.go @@ -403,6 +403,10 @@ func (sb *SegmentBase) InterpretVectorIndex(field string, requiresFiltering bool vectorIDsToInclude = append(vectorIDsToInclude, docVecIDMap[uint32(id)]...) } + if len(vectorIDsToInclude) == 0 { + return rv, nil + } + // Retrieve the mapping of centroid IDs to vectors within // the cluster. clusterAssignment, _ := vecIndex.ObtainClusterToVecIDsFromIVFIndex()