Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MB-60400: Do not walk document if vector is processed successfully #1984

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions mapping/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,14 @@ func (dm *DocumentMapping) processProperty(property interface{}, path []string,
dm.walkDocument(property, path, indexes, context)
}
case reflect.Map, reflect.Slice:
var isPropertyVector bool
if subDocMapping != nil {
for _, fieldMapping := range subDocMapping.Fields {
switch fieldMapping.Type {
case "vector":
fieldMapping.processVector(property, pathString, path,
processed := fieldMapping.processVector(property, pathString, path,
indexes, context)
isPropertyVector = isPropertyVector && processed
case "geopoint":
fieldMapping.processGeoPoint(property, pathString, path, indexes, context)
case "IP":
Expand All @@ -550,7 +552,9 @@ func (dm *DocumentMapping) processProperty(property interface{}, path []string,
}
}
}
dm.walkDocument(property, path, indexes, context)
if !isPropertyVector {
dm.walkDocument(property, path, indexes, context)
}
case reflect.Ptr:
if !propertyValue.IsNil() {
switch property := property.(type) {
Expand Down
4 changes: 2 additions & 2 deletions mapping/mapping_no_vectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func NewVectorFieldMapping() *FieldMapping {
}

func (fm *FieldMapping) processVector(propertyMightBeVector interface{},
pathString string, path []string, indexes []uint64, context *walkContext) {

pathString string, path []string, indexes []uint64, context *walkContext) bool {
return false
}

// -----------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions mapping/mapping_vectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func processVector(vecI interface{}, dims int) ([]float32, bool) {
}

func (fm *FieldMapping) processVector(propertyMightBeVector interface{},
pathString string, path []string, indexes []uint64, context *walkContext) {
pathString string, path []string, indexes []uint64, context *walkContext) bool {
vector, ok := processVector(propertyMightBeVector, fm.Dims)
// Don't add field to document if vector is invalid
if !ok {
return
return false
}

fieldName := getFieldName(pathString, path, fm)
Expand All @@ -137,6 +137,7 @@ func (fm *FieldMapping) processVector(propertyMightBeVector interface{},

// "_all" composite field is not applicable for vector field
context.excludedFromAll = append(context.excludedFromAll, fieldName)
return true
}

// -----------------------------------------------------------------------------
Expand Down
Loading