You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Vector data serialization [vector-data-serialization]
459
+
460
+
Efficient ingestion of high-dimensional vectors often benefits from compact encodings rather than verbose JSON arrays. The client provides opt‑in converters for vector properties in your source documents that serialize to either hexadecimal or `base64` strings, depending on the vector type and the Elasticsearch version you target.
461
+
462
+
- Float vectors can use `base64` starting from Elasticsearch 9.3.0.
463
+
- Byte/bit vectors can use hexadecimal strings starting from Elasticsearch 8.14.0 and `base64` starting from Elasticsearch 9.3.0.
464
+
- The legacy representation (JSON arrays) remains available for backwards compatibility.
465
+
466
+
Base64 is the preferred format for high‑throughput indexing because it minimizes payload size and reduces JSON parsing overhead.
467
+
468
+
### Opt‑in on document properties [optin-on-document-properties]
469
+
470
+
Vector encodings are opt‑in. Apply a `System.Text.Json``JsonConverter` attribute on the vector property of your POCO. For best performance, model the properties as `ReadOnlyMemory<T>`.
When the opt‑in attributes are present, you can control the actual wire encoding globally via `ElasticsearchClient` settings on a per‑type basis:
498
+
499
+
-`FloatVectorDataEncoding`: controls float vector encoding (legacy arrays or `base64`).
500
+
-`ByteVectorDataEncoding`: controls byte/bit vector encoding (legacy arrays, hexadecimal, or `base64`).
501
+
502
+
These settings allow a single set of document types to work against mixed clusters. For example, a library using the 8.19.x client can talk to both 8.x and 9.x servers and dynamically opt out of `base64` on older servers without maintaining duplicate POCOs (with/without converter attributes).
503
+
504
+
::::{note}
505
+
506
+
Set the encoding based on your effective server version:
507
+
508
+
- Float vectors: use `base64` for 9.3.0+; otherwise use legacy arrays.
509
+
- Byte/bit vectors: prefer `base64` for 9.3.0+; use hexadecimal for 8.14.0–9.2.x; otherwise use legacy arrays.
0 commit comments