In diesem Dokument erfahren Sie, wie Sie gespeicherte Einbettungen verwenden, um Indexe zu generieren und Einbettungen abzufragen. Weitere Informationen zum Speichern von Einbettungen finden Sie unter Vektoreinbettungen speichern.
Sie können ScaNN-, IVF-, IVFFlat- und HNSW-Indizes mit AlloyDB erstellen.
Hinweise
Bevor Sie mit dem Erstellen von Indexen beginnen können, müssen Sie die folgenden Voraussetzungen erfüllen.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[],[],null,["# Create indexes and query vectors\n\nSelect a documentation version: 15.12.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/ai/store-index-query-vectors)\n- [16.8.0](/alloydb/omni/16.8.0/docs/ai/store-index-query-vectors)\n- [16.3.0](/alloydb/omni/16.3.0/docs/ai/store-index-query-vectors)\n- [15.12.0](/alloydb/omni/15.12.0/docs/ai/store-index-query-vectors)\n- [15.7.1](/alloydb/omni/15.7.1/docs/ai/store-index-query-vectors)\n- [15.7.0](/alloydb/omni/15.7.0/docs/ai/store-index-query-vectors)\n\n\u003cbr /\u003e\n\nThis document shows you how to use stored embeddings to generate indexes and query\nembeddings. For more information about storing embedding, see\n[Store vector embeddings](/alloydb/omni/15.12.0/docs/ai/store-embeddings).\n\nYou can create `ScaNN`, `IVF`, `IVFFlat`, and `HNSW` indexes with AlloyDB.\n| **Caution:** The `postgres_ann` extension is renamed to `alloydb_scann`. Before you upgrade to AlloyDB Omni, you must drop any indexes created using the older `postgres_ann` version. Next, upgrade AlloyDB Omni, and then [create the indexes](#create-index) again using the `alloydb_scann` extension. This applies only to AlloyDB Omni.\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/omni/15.12.0/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- [An example embedding workflow](/alloydb/omni/15.12.0/docs/ai/example-embeddings)\n- [Tune vector query performance](/alloydb/omni/15.12.0/docs/ai/tune-indexes)\n- [Vector index metrics](/alloydb/omni/15.12.0/docs/reference/vector-index-metrics)"]]