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)."],[[["\u003cp\u003eThis guide outlines how to generate and query indexes using stored embeddings within AlloyDB.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB supports the creation of \u003ccode\u003eScaNN\u003c/code\u003e, \u003ccode\u003eIVF\u003c/code\u003e, \u003ccode\u003eIVFFlat\u003c/code\u003e, and \u003ccode\u003eHNSW\u003c/code\u003e index types for efficient data retrieval.\u003c/p\u003e\n"],["\u003cp\u003ePrior to index creation, ensure that embedding vectors are stored in a table, the \u003ccode\u003evector\u003c/code\u003e extension (version 0.5.0 or later) is installed, and, for \u003ccode\u003eScaNN\u003c/code\u003e indexes, the \u003ccode\u003ealloydb_scann\u003c/code\u003e extension is installed.\u003c/p\u003e\n"],["\u003cp\u003eWhen upgrading to AlloyDB Omni, drop any indexes created with the \u003ccode\u003epostgres_ann\u003c/code\u003e extension and recreate them using \u003ccode\u003ealloydb_scann\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Create indexes and query vectors\n\nSelect a documentation version: Current (16.8.0)keyboard_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/current/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/current/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/current/docs/ai/example-embeddings)\n- [Tune vector query performance](/alloydb/omni/current/docs/ai/tune-indexes)\n- [Vector index metrics](/alloydb/omni/current/docs/reference/vector-index-metrics)"]]