Skip to content

V4.0.0 - Vector Search

Latest
Compare
Choose a tag to compare
@greenrobot-team greenrobot-team released this 16 May 07:24

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
public class City {

    @HnswIndex(dimensions = 2)
    float[] location;
    
}

Perform a nearest neighbor search using the new nearestNeighbors(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 float[] madrid = {40.416775F, -3.703790F};
final Query<City> query = box
        .query(City_.location.nearestNeighbors(madrid, 2))
        .build();
final City closest = query.findWithScores().get(0).get();

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

  • BoxStore: deprecated BoxStore.sizeOnDisk(). Instead use one of the new APIs to determine the size of a database:
    • BoxStore.getDbSize() which for a file-based database returns the file size and for an in-memory database returns the approximately used memory,
    • BoxStore.getDbSizeOnDisk() which only returns a non-zero size for a file-based database.
  • Query: add properly named setParameter(prop, value) methods that only accept a single parameter value, deprecated the old setParameters(prop, value) variants.
  • Sync: add SyncCredentials.userAndPassword(user, password).
  • Gradle plugin: the license of the Gradle plugin has changed to the GNU Affero General Public License (AGPL).