Doc class
A document in a Zvec collection.
Documents contain scalar fields and vector embeddings. Each document has a primary key (pk) that uniquely identifies it.
Example:
final doc = Doc(id: 'doc_1')
..setField('title', 'Hello World')
..setVector('embedding', Float32List.fromList([0.1, 0.2, 0.3, 0.4]));
Constructors
-
Doc({String? id, Map<
String, dynamic> ? fields}) - Create a new empty document.
-
Doc.fromNativePtr(Pointer<
zvec_doc_t> ptr) -
Create from a native pointer (non-owning). Used internally by Collection.
factory
-
Doc.fromOwnedNativePtr(Pointer<
zvec_doc_t> ptr) -
Create from a native pointer and take ownership of it.
factory
Properties
- docId → int
-
Get the internal document ID.
no setter
- fieldCount → int
-
Get the number of fields in this document.
no setter
-
fieldNames
→ List<
String> -
Get all field names.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the document has no fields.
no setter
-
nativePtr
→ Pointer<
zvec_doc_t> -
The native pointer for internal use.
no setter
- pk ↔ String?
-
Get the primary key.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- score → double
-
Get the document score (set after query operations).
no setter
Methods
-
destroy(
) → void - Destroy the native document. Only call if this object owns the pointer.
-
getBool(
String name) → bool? - Get a bool field value.
-
getDouble(
String name) → double? - Get a double field value.
-
getFloat(
String name) → double? - Get a float field value.
-
getInt64(
String name) → int? - Get an int64 field value.
-
getString(
String name) → String? - Get a string field value.
-
getVector(
String name) → Float32List? - Get a FP32 vector field value.
-
hasField(
String name) → bool - Check if a field exists.
-
isFieldNull(
String name) → bool - Check if a field is null.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setField(
String name, dynamic value) → void - Set a scalar field value. Supported types:
-
setFieldNull(
String name) → void - Mark a field as null.
-
setVector(
String name, Float32List vector) → void - Set a FP32 vector field.
-
setVector64(
String name, Float64List vector) → void - Set a FP64 vector field.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited