Skip to content

V4.0 Vector Search

Compare
Choose a tag to compare
@greenrobot-team greenrobot-team released this 16 May 08:18
· 12 commits to main since this release

To upgrade to this major release run flutter pub upgrade objectbox --major-versions
(or for Dart Native apps dart pub upgrade objectbox --major-versions).

ObjectBox now supports Vector Search to enable efficient similarity searches.

This is particularly useful for AI/ML/RAG applications, e.g. image, audio, or text similarity. Other use cases include semantic search or recommendation engines.

Create a Vector (HNSW) index for a floating point vector property. For example, a City with a location vector:

@Entity()
class City {

  @HnswIndex(dimensions: 2)
  @Property(type: PropertyType.floatVector)
  List<double>? location;

}

Perform a nearest neighbor search using the new nearestNeighborsF32(queryVector, maxResultCount)
query condition and the new "find with scores" query methods (the score is the distance to the
query vector). For example, find the 2 closest cities:

final madrid = [40.416775, -3.703790];
final query = box
    .query(City_.location.nearestNeighborsF32(madrid, 2))
    .build();
final closest = query.findWithScores()[0].object;

For an introduction to Vector Search, more details and other supported languages see the
Vector Search documentation.

  • The generator correctly errors when using an unsupported index on a vector type.
  • Flutter for Linux/Windows, Dart Native: update to objectbox-c 4.0.0.
  • Flutter for Android: update to objectbox-android 4.0.0.
    If you are using Admin, make sure to
    update to io.objectbox:objectbox-android-objectbrowser:4.0.0 in android/app/build.gradle.
  • Flutter for iOS/macOS: update to objectbox-swift 2.0.0.
    Existing projects may have to run pod repo update and pod update ObjectBox.