skip nodes with level too low in searchLayerByVector
@@ -198,6 +198,14 @@ func (h *hnsw) searchLayerByVector(queryVector []float32,
}
candidateNode.Lock()
+ if candidateNode.level < level {
+ // a node level could have been downgraded as part of a delete-reassign,
+ // but the connections pointing to it not yet cleaned up. In this case
+ // the node doesn't have any outgoing connections at this level and we
+ // must discard it.
+ candidateNode.Unlock()
+ continue
+ }
var connections *[]uint64
