Vector Search
Vector search requires the Enterprise edition and is supported on ARM64 and x86-64.
Configuration
To enable vector search, configure your package pubspec.yaml:
hooks:
user_defines:
cbl:
edition: enterprise
vector_search: true
If you are using a Dart pub workspace, hooks.user_defines are read from the
workspace root pubspec.yaml, so put this configuration there instead.
The build hook will automatically download the required vector search extension library alongside the other native libraries.
If vector_search is not set to true, the extension library is not bundled
and does not occupy any space in your app bundle.
Enabling vector search
Vector search must be explicitly enabled after calling CouchbaseLite.init
and before opening a database that uses it:
await CouchbaseLite.init();
try {
final status = Extension.enableVectorSearch();
if (status != VectorSearchStatus.enabled) {
// Handle the case where vector search is unavailable on this system.
print('Vector search status: $status');
}
} on DatabaseException catch (e) {
print('Vector search could not be enabled: $e');
}
You can also check the status without attempting to enable:
final status = Extension.vectorSearchStatus;
If the vector search library is bundled but its file path cannot be resolved,
both Extension.vectorSearchStatus and Extension.enableVectorSearch() throw a
DatabaseException.
VectorSearchStatus values
| Value | Meaning |
|---|---|
available | The vector search library is bundled and the system supports it. Call Extension.enableVectorSearch() to enable. |
enabled | Vector search has been successfully enabled. |
libraryNotAvailable | The vector search library was not bundled. Set vector_search: true in pubspec.yaml. |
systemNotSupported | The current system does not support vector search. Vector search is supported on ARM64 and x86-64. On x86-64, the CPU must additionally support the AVX2 instruction set. |
Usage
Vector search is available but the Dart specific documentation for vector search is not available yet.
Since the Dart API is very similar to the Swift API, you can refer to the Swift documentation in the meantime.