Skip to main content
If you already generate embeddings, store them in a dense_vector field on a document index. This fits when you use a model Pinecone doesn’t host, a model you’ve fine-tuned, or vectors you’ve already computed. You embed every document before you upsert it and every query before you search. To have Pinecone embed your text instead, use integrated embedding. For a legacy vector index, see Create a vector index, Upsert vectors, and Query vectors. The steps use an SDK or the REST API, with your API key in the PINECONE_API_KEY environment variable. To set them up, see the quickstart. The JavaScript examples use top-level await, so run them as an ES module. The Go examples build one main function: the first block is the full program, and each later block adds to it.
1

Generate embeddings for your documents

Embed each document’s text with the model of your choice. So the example runs as is, it uses Pinecone’s hosted llama-text-embed-v2 model through the standalone embedding API, which returns 1,024-dimension vectors. Set input_type to passage for documents.
2

Create an index with a dense_vector field

Declare a dense_vector field whose dimension matches your model’s output and whose metric matches what the model was trained for. llama-text-embed-v2 uses cosine. This schema also declares chunk_text with full_text_search, so the index stores each document’s text and can rank it by keyword too. Fields you don’t declare are stored as metadata.
3

Upsert documents with their vectors

Put each vector on the embedding field, next to the text it came from. Each vector must have exactly 1,024 values. Documents are indexed asynchronously, so the code waits 10 seconds before you search.
4

Embed your query

Embed the query with the same model you used for the documents. Vectors from different models aren’t comparable, so a different model returns meaningless rankings. For llama-text-embed-v2, set input_type to query.
5

Search by vector similarity

Score by dense_vector and pass the query vector in values. Pinecone ranks documents by the field’s metric.
The refund policy ranks first:
Output
Because chunk_text declares full_text_search, the same index also supports a full-text search on the text, and either search accepts a metadata filter.