Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara menggunakan penyematan tersimpan untuk membuat indeks dan membuat kueri
penyematan menggunakan indeks ScaNN, IVF, IVFFlat, dan HNSW dengan AlloyDB untuk PostgreSQL.
Untuk informasi selengkapnya tentang menyimpan penyematan, lihat
Menyimpan penyematan vektor.
Sebelum memulai
Sebelum dapat mulai membuat indeks, Anda harus menyelesaikan prasyarat
berikut.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-03 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)."]]