Fix nullState/prop length buckets for properties that are added later
@@ -81,20 +81,40 @@ func (m *Migrator) AddClass(ctx context.Context, class *models.Class,
if prop.IndexInverted != nil && !*prop.IndexInverted {
continue
}
+ errProps := m.addPropertiesAndNullAndLength(ctx, prop, idx)
+ if errProps != nil {
+ return errors.Wrapf(errProps, "add prop and null state and property length '%v'", prop)
+ }
+ }
+
+ if m.db.config.TrackVectorDimensions {
+ if err := idx.addDimensionsProperty(context.TODO()); err != nil {
+ return errors.Wrap(err, "init id property")
+ }
+ }
+ m.db.indexLock.Lock()
+ m.db.indices[idx.ID()] = idx
+ idx.notifyReady()
+ m.db.indexLock.Unlock()
+
+ return nil
+}
+
+func (m *Migrator) addPropertiesAndNullAndLength(ctx context.Context, prop *models.Property, idx *Index) error {
err := idx.addProperty(ctx, prop)
if err != nil {
return errors.Wrapf(err, "extend idx '%s' with property", idx.ID())
}
- if class.InvertedIndexConfig.IndexNullState {
+ if idx.invertedIndexConfig.IndexNullState {
err = idx.addNullStateProperty(ctx, prop)
if err != nil {
return errors.Wrapf(err, "extend idx '%s' with nullstate properties", idx.ID())
}
}
- if class.InvertedIndexConfig.IndexPropertyLength {
+ if idx.invertedIndexConfig.IndexPropertyLength {
dt := schema.DataType(prop.DataType[0])
// some datatypes are not added to the inverted index, so we can skip them here
switch dt {
@@ -107,19 +127,6 @@ func (m *Migrator) AddClass(ctx context.Context, class *models.Class,
}
}
}
- }
-
- if m.db.config.TrackVectorDimensions {
- if err := idx.addDimensionsProperty(context.TODO()); err != nil {
- return errors.Wrap(err, "init id property")
- }
- }
-
- m.db.indexLock.Lock()
- m.db.indices[idx.ID()] = idx
- idx.notifyReady()
- m.db.indexLock.Unlock()
-
return nil
}
@@ -146,7 +153,7 @@ func (m *Migrator) AddProperty(ctx context.Context, className string, prop *mode
return errors.Errorf("cannot add property to a non-existing index for %s", className)
}
- return idx.addProperty(ctx, prop)
+ return m.addPropertiesAndNullAndLength(ctx, prop, idx)
}
// DropProperty is ignored, API compliant change
