[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThis document explains how to create and use \u003ccode\u003eScaNN\u003c/code\u003e, \u003ccode\u003eIVF\u003c/code\u003e, \u003ccode\u003eIVFFlat\u003c/code\u003e, and \u003ccode\u003eHNSW\u003c/code\u003e indexes with AlloyDB to query stored embeddings.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating indexes, ensure that embedding vectors are added to a table, the \u003ccode\u003evector\u003c/code\u003e extension (version 0.5.0 or later) is installed, and the \u003ccode\u003ealloydb_scann\u003c/code\u003e extension is installed for \u003ccode\u003eScaNN\u003c/code\u003e indexes.\u003c/p\u003e\n"],["\u003cp\u003eIf you are upgrading to AlloyDB Omni, you must drop any indexes created with the older \u003ccode\u003epostgres_ann\u003c/code\u003e extension and recreate them using the \u003ccode\u003ealloydb_scann\u003c/code\u003e extension.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ealloydb_scann\u003c/code\u003e extension is a prerequisite for creating ScaNN indexes and can be used with PostgreSQL 14 and 15 compatible databases.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eScaNN\u003c/code\u003e index feature is in Pre-GA and subject to limited support, according to the Pre-GA Offerings Terms in the Service Specific Terms.\u003c/p\u003e\n"]]],[],null,["# Create indexes and query vectors\n\nSelect a documentation version: 15.5.5keyboard_arrow_down\n\n- [15.5.5](/alloydb/omni/15.5.5/docs/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.5.5/docs/store-embeddings).\n|\n| **Preview\n| --- AlloyDB ScaNN index**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\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.5.5/docs/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.5.5/docs/example-embeddings)\n- [Tune vector query performance](/alloydb/omni/15.5.5/docs/tune-indexes)\n- [Vector index metrics](/alloydb/docs/reference/vector-index-metrics)"]]