Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta página descreve como usar embeddings armazenados para gerar índices e consultar embeddings usando índices ScaNN, IVF, IVFFlat e HNSW com o AlloyDB para PostgreSQL.
Para mais informações sobre como armazenar embeddings, consulte
Armazenar embeddings de vetor.
Antes de começar
Antes de começar a criar índices, conclua os seguintes
pré-requisitos.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-25 UTC."],[[["\u003cp\u003eThis page guides you on creating and querying indexes using stored embeddings with \u003ccode\u003eScaNN\u003c/code\u003e, \u003ccode\u003eIVF\u003c/code\u003e, \u003ccode\u003eIVFFlat\u003c/code\u003e, and \u003ccode\u003eHNSW\u003c/code\u003e indexes in AlloyDB for PostgreSQL.\u003c/p\u003e\n"],["\u003cp\u003ePrerequisites include having embedding vectors in an AlloyDB table and installing the \u003ccode\u003evector\u003c/code\u003e extension version \u003ccode\u003e0.5.0\u003c/code\u003e or later.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ealloydb_scann\u003c/code\u003e extension, compatible with PostgreSQL 14 and 15, must also be installed to create \u003ccode\u003eScaNN\u003c/code\u003e indexes.\u003c/p\u003e\n"],["\u003cp\u003eYou can create various index types, such as \u003ccode\u003eScaNN\u003c/code\u003e, \u003ccode\u003eIVF\u003c/code\u003e, \u003ccode\u003eIVFFlat\u003c/code\u003e, and \u003ccode\u003eHNSW\u003c/code\u003e, but remember that index names are shared across the database.\u003c/p\u003e\n"]]],[],null,["# Create indexes\n\nThis page describes how to use stored embeddings to generate indexes and query\nembeddings using `ScaNN`, `IVF`, `IVFFlat`, and `HNSW` indexes with AlloyDB for PostgreSQL.\nFor more information about storing embedding, see\n[Store vector embeddings](/alloydb/docs/ai/store-embeddings).\n\nBefore you begin\n----------------\n\nBefore you can start creating indexes, you must complete the following\nprerequisites.\n\n- [Embedding vectors are added to a table](/alloydb/docs/ai/store-embeddings) in your\n AlloyDB database.\n\n- The `vector` extension version `0.5.0` or later that is based on `pgvector`, extended by Google for\n AlloyDB is installed.\n\n CREATE EXTENSION IF NOT EXISTS vector;\n\n- To generate `ScaNN` indexes, install the `alloydb_scann` extension in addition\n to the `vector` extension.\n\n CREATE EXTENSION IF NOT EXISTS alloydb_scann;\n\n| **Note:** The `alloydb_scann` extension can be used with PostgreSQL 14 and 15 compatible databases.\n\nCreate an index\n---------------\n\nYou can create one of the following index types for tables in your database.\n**Note:** As the index names are shared across the database, create an index name unique to each table in your database. \nScaNN IVF IVFFlat HNSW\n\nWhat's next\n-----------\n\n- [Run vector similarity searches](/alloydb/docs/ai/run-vector-similarity-search)\n- [Tune vector query performance](/alloydb/docs/ai/tune-indexes)\n- [Vector index metrics](/alloydb/docs/reference/vector-index-metrics)\n- [Learn how to build a smart shopping assistant with AlloyDB, pgvector, and model endpoint management](https://codelabs.developers.google.com/smart-shop-agent-alloydb#0)."]]