Skip to content
← Back to activity

Immutable solution version

Astra DB Java SDK: @Vectorize for automatic vectorization, @Vector only for precomputed embeddings

Version 2Sign in to save

Complete solution

Practical fix from a real DataStax Astra DB issue: Astra DB Java SDK: @Vectorize for automatic vectorization, @Vector only for precomputed embeddings

Astra DB Java SDK: @Vectorize for automatic vectorization, @Vector only for precomputed embeddings

TL;DR

The Astra DB Java SDK has two vector annotations that are easy to confuse, and picking the wrong one means embeddings are never generated or are stored twice. @Vectorize hands embedding generation to Astra (Vectorize); @Vector stores embeddings you computed yourself. The astra-db-java object-mapping guide's best practices say: "Choose between @Vectorize and @Vector: Use @Vectorize for automatic vectorization, @Vector for pre-computed embeddings." A field may also carry only one special annotation (@DocumentId, @Vectorize, @Lexical, or @Vector), so stacking them fails.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

When using vector features, always set vectorDimension on the collection (for example 1536 for text-embedding-ada-002) and configure the vectorize provider and model to match.

Evidence

The Astra DB Java SDK has two vector annotations that are easy to confuse, and picking the wrong one means embeddings are never generated or are stored twice. @Vectorize hands embedding generation to Astra (Vectorize); @Vector stores embeddings you computed yourself. The astra-db-java object-mapping guide's best practices say: "Choose between @Vectorize and @Vector: Use @Vectorize for automatic vectorization, @Vector for pre-computed embeddings." A field may also carry only one special annotation (@DocumentId, @Vectorize, @Lexical, or @Vector), so stacking them fails. When using vector features, always set vectorDimension on the collection (for example 1536 for text-embedding-ada-002) and configure the vectorize provider and model to match. Verified answer: The Astra DB Java SDK has two vector annotations that are easy to confuse, and picking the wrong one means embeddings are never generated or are stored twice. @Vectorize hands embedding generation to Astra (Vectorize); @Vector stores embeddings you computed yourself. The astra-db-java object-mapping guide's best practices say: "Choose between @Vectorize and @Vector: Use @Vectorize for automatic vectorization, @Vector for pre-computed embeddings." A field may also carry only one special annotation (@DocumentId, @Vectorize, @Lexical, or @Vector), so stacking them fails. When using vector features, always set vectorDimension on the collection (for example 1536 for text-embedding-ada-002) and configure the vectorize provider and model to match. Source: https://github.com/datastax/astra-db-java/blob/HEAD/samples/sample-spring-boot3x/OBJECT-MAPPING-GUIDE.md

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_5_mB-CHdAsLMYe0vd25vbA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Astra DB Java SDK: @Vectorize for automatic vectorization, @Vector only for precomputed embeddings <span>— Vectle</span></a>