Skip to content

Commit a4d9056

Browse files
MB-60786: Vector search will not be supported in a mixed cluster
+ We already accounted for the situation where a user does a rolling online upgrade from pre-7.6 to 7.6. + This fix will address the situation where the user upgrades from CE to EE. Change-Id: I41193b40015fd3ad729387deeb68a88605836fbf Reviewed-on: https://review.couchbase.org/c/cbft/+/205688 Well-Formed: Restriction Checker Well-Formed: Build Bot <[email protected]> Tested-by: Abhi Dangeti <[email protected]> Reviewed-by: Abhi Dangeti <[email protected]>
1 parent 21bd238 commit a4d9056

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

cmd/cbft/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func mainStart(cfg cbgt.Cfg, uuid string, tags []string, container string,
342342
"," + cbft.FeatureBlevePreferredSegmentVersion +
343343
"," + cbft.FeatureFileTransferRebalance +
344344
"," + cbft.FeatureGeoSpatial +
345-
"," + cbft.FeatureVectorSupportVersion
345+
cbft.FeatureVectorSearchSupport()
346346

347347
extrasMap["version-cbft.app"] = version
348348
extrasMap["version-cbft.lib"] = cbft.VERSION

knn_nosup.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import (
1717
"github.com/blevesearch/bleve/v2"
1818
)
1919

20+
func FeatureVectorSearchSupport() string {
21+
return ""
22+
}
23+
24+
// -----------------------------------------------------------------------------
25+
2026
func interpretKNNForRequest(knn, knnOperator json.RawMessage, r *bleve.SearchRequest) (
2127
*bleve.SearchRequest, error) {
2228
// Not supported

knn_sup.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import (
1717
"github.com/blevesearch/bleve/v2"
1818
)
1919

20+
func FeatureVectorSearchSupport() string {
21+
return "," + FeatureVectorSearch
22+
}
23+
24+
// -----------------------------------------------------------------------------
25+
2026
func interpretKNNForRequest(knn, knnOperator json.RawMessage, r *bleve.SearchRequest) (
2127
*bleve.SearchRequest, error) {
2228
if knn != nil && r != nil {

pindex_bleve.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ var FeatureCollections = cbgt.SOURCE_GOCBCORE + ":collections"
6161

6262
var FeatureGeoSpatial = "geoSpatial"
6363

64+
var FeatureVectorSearch = "vectors"
65+
6466
var FeatureBlevePreferredSegmentVersion = fmt.Sprintf("segmentVersion:%d", BlevePreferredZapVersion)
6567

6668
var BleveMaxOpsPerBatch = 200 // Unlimited when <= 0.
@@ -537,6 +539,8 @@ func PrepareIndexDef(mgr *cbgt.Manager, indexDef *cbgt.IndexDef) (
537539
indexDef.SourceType = cbgt.SOURCE_GOCBCORE
538540
}
539541

542+
var vectorFieldsSpecifiedInMapping bool
543+
540544
bp := NewBleveParams()
541545
if len(indexDef.Params) > 0 {
542546
b, err := bleveMappingUI.CleanseJSON([]byte(indexDef.Params))
@@ -608,10 +612,12 @@ func PrepareIndexDef(mgr *cbgt.Manager, indexDef *cbgt.IndexDef) (
608612
}
609613
}
610614

611-
if !isClusterCompatibleFor(FeatureVectorSupportVersion) {
615+
vectorFieldsSpecifiedInMapping = vectorFieldsExistWithinIndexMapping(bp.Mapping)
616+
if !isClusterCompatibleFor(FeatureVectorSearchSupportVersion) ||
617+
!cbgt.IsFeatureSupportedByCluster(FeatureVectorSearch, nodeDefs) {
612618
// Vector indexing & search is NOT supported on this cluster
613619
// (lower version or mixed lower version)
614-
if vectorFieldsExistWithinIndexMapping(bp.Mapping) {
620+
if vectorFieldsSpecifiedInMapping {
615621
return nil, cbgt.NewBadRequestError("PrepareIndex, err: vector typed fields " +
616622
"not supported in mixed version cluster")
617623
}
@@ -634,7 +640,7 @@ func PrepareIndexDef(mgr *cbgt.Manager, indexDef *cbgt.IndexDef) (
634640
"supported", int(zv))
635641
}
636642

637-
if vectorFieldsExistWithinIndexMapping(bp.Mapping) && int(zv) < BleveVectorZapVersion {
643+
if vectorFieldsSpecifiedInMapping && int(zv) < BleveVectorZapVersion {
638644
// overrride segmentVersion to minimum version needed to support vector mappings
639645
bp.Store["segmentVersion"] = BleveVectorZapVersion
640646
}
@@ -647,7 +653,7 @@ func PrepareIndexDef(mgr *cbgt.Manager, indexDef *cbgt.IndexDef) (
647653
// zap version for newer indexes in a sufficiently advanced
648654
// cluster, else consider the default zap version.
649655
if segmentVersionSupported {
650-
if vectorFieldsExistWithinIndexMapping(bp.Mapping) {
656+
if vectorFieldsSpecifiedInMapping {
651657
bp.Store["segmentVersion"] = BleveVectorZapVersion
652658
} else {
653659
bp.Store["segmentVersion"] = BlevePreferredZapVersion

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const FeatureGrpcVersion = "6.5.0"
4545

4646
const FeatureScopedIndexNamesVersion = "7.5.0"
4747

48-
const FeatureVectorSupportVersion = "7.6.0"
48+
const FeatureVectorSearchSupportVersion = "7.6.0"
4949

5050
func HandleAPIVersion(h string) (string, error) {
5151
if len(h) <= 0 || h == "*/*" {

0 commit comments

Comments
 (0)