nearest_neighbors{neighbors{datapoint{datapoint_id:"4"feature_vector:0.7feature_vector:0.8restricts{namespace:"genre"allow_list:"Drama"}embedding_metadata{title:"A Movie"description:"The story of A Movie..."}crowding_tag{crowding_attribute:"0"}numeric_restricts{namespace:"year"value_int:1942}}distance:0.75}}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-02。"],[],[],null,["# Import index data from BigQuery\n\n| **Preview**\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\nThis guide explains how to import index data from BigQuery into\nVector Search with the `ImportIndex` API, streamlining\nthe process of populating Vector Search indexes directly from\nyour BigQuery tables that contain vector embeddings.\n\nPreparing BigQuery data for import\n----------------------------------\n\nBefore importing index data, your BigQuery table must have the\nfollowing columns:\n\n- **Unique identifiers** : This column contains unique identifiers for each\n data point. It is mapped to the `id` field in Vector Search.\n\n- **Vector embeddings** : This column contains the vector embeddings,\n represented as a repeated `FLOAT` field. It is mapped to the embedding\n field in Vector Search.\n\nOptionally, you can include the following columns:\n\n- **Restricts**: These are columns for string and numeric restricts, which\n lets you filter your data during searches.\n\n- **Metadata**: These are columns of metadata to be returned with\n Vector Search index query results.\n\nPreparing Vector Search index for import\n----------------------------------------\n\nOnce you've prepared your BigQuery data, ensure the destination\nVector Search index:\n\n- **Exists in Vector Search within your project**: This index\n serves as the destination for your imported data. The index must be created\n within your project.\n\n- **Is set to overwrite or append data**: During the import process, you\n have the option to either overwrite the existing data within your\n Vector Search index or append the data imported from\n BigQuery. Overwriting replaces the current data points\n with the imported data. Appending adds the new data to the existing\n index.\n\n- **Matches dimensionality**: The dimensionality of the embeddings stored in\n your BigQuery data must be identical to the dimensionality\n configured for your Vector Search index.\n\nSpecifying the `ImportIndexRequest`\n-----------------------------------\n\nBefore importing data from BigQuery, create an\n`ImportIndexRequest` object that specifies the target index, whether to\noverwrite existing data, and the configuration for connecting to\nBigQuery. Send this request object to the `ImportIndex`\nAPI.\n\nThe following is an example of an `ImportIndexRequest` in JSON format: \n\n {\n \"name\": \"projects/[PROJECT_ID]/locations/[LOCATION]/indexes/[INDEX_ID]\",\n \"isCompleteOverwrite\": true,\n \"config\": {\n \"bigQuerySourceConfig\": {\n \"tablePath\": \"[PROJECT_ID].[DATASET_ID].[TABLE_ID]\",\n \"datapointFieldMapping\": {\n \"idColumn\": \"[ID_COLUMN_NAME]\",\n \"embeddingColumn\": \"[EMBEDDING_COLUMN_NAME]\",\n \"restricts\": [\n {\n \"namespace\": \"[RESTRICT_NAMESPACE]\",\n \"allowColumn\": [\"[RESTRICT_ALLOW_COLUMN_NAME]\"],\n \"denyColumn\": [\"[RESTRICT_DENY_COLUMN_NAME]\"]\n }\n ],\n \"numericRestricts\": [\n {\n \"namespace\": \"[RESTRICT_NAMESPACE]\",\n \"valueColumn\": \"[RESTRICT_VALUE_COLUMN_NAME]\",\n \"valueType\": \"INT\"\n }\n ],\n \"metadataColumns\": [\"METADATA_COLUMN1\", \"METADATA_COLUMN2\", ...]\n }\n }\n }\n }\n\n- **`name`**: The full resource name of the Vector Search index\n where you want to import the data.\n\n- **`isCompleteOverwrite`** : A boolean that indicates whether to overwrite existing\n data in the index. Set to `true` to replace existing data.\n\n- **`config`**: Contains the configuration for the BigQuery source.\n\n - **`bigquerySourceConfig`**: Specifies the details for connecting to your\n BigQuery table.\n\n - **`tablePath`** : The full path to your BigQuery table in the\n format `[PROJECT_ID].[DATASET_ID].[TABLE_ID]`.\n\n - **`datapointFieldMapping`**: Maps the columns in your\n BigQuery table to the fields in Vector Search.\n\n - **`idColumn`**: The name of the column containing unique identifiers.\n\n - **`embeddingColumn`**: The name of the column containing vector\n embeddings.\n\n - **`restricts`**: (Optional) Specifies string restricts.\n\n - **`namespace`**: The namespace for the restrict.\n\n - **`allowColumn`**: The array containing column name(s) for allowed\n values for the restrict.\n\n - **`denyColumn`**: The array containing column name(s) for denied values\n for the restrict.\n\n - **`numericRestricts`**: (Optional) Specifies numeric restricts.\n\n - **`namespace`**: The namespace for the numeric restrict.\n\n - **`value_column`**: The name of the column containing numeric values.\n\n - **`value_type`** : The type of the numeric value such as `INT`,\n `FLOAT`, or `DOUBLE`.\n\n - **`metadataColumns`**: (Optional) Metadata fields to include with the\n feature embedding. These metadata fields can be retrieved from the index\n search results, but they don't affect the search itself. For example,\n filtering cannot be performed on metadata fields.\n\nExecuting the import\n--------------------\n\nOnce you have created an `ImportIndexRequest`, send it to the `ImportIndex` API\nendpoint. This triggers the import process, which exports data from\nBigQuery and ingests it into your Vector Search\nindex. `ImportIndex` returns a long-running operation. You can use the operation\nID to monitor the progress of the import operation.\n\nAfter the imported data is stored, it resides within your\nVector Search index and is indistinguishable from data ingested\nusing other methods. The index can continue to be managed using standard\nVector Search APIs.\n\nThe following code sample demonstrates a query result with\n`return_full_datapoint` set to true and the BigQuery connector\nconfiguration that specifies a `genre` restricts, a `year` numeric restricts,\nand metadata columns `title` and `description`. \n\n nearest_neighbors {\n neighbors {\n datapoint {\n datapoint_id: \"4\"\n feature_vector: 0.7\n feature_vector: 0.8\n restricts {\n namespace: \"genre\"\n allow_list: \"Drama\"\n }\n embedding_metadata {\n title: \"A Movie\"\n description: \"The story of A Movie...\"\n }\n crowding_tag {\n crowding_attribute: \"0\"\n }\n numeric_restricts {\n namespace: \"year\"\n value_int: 1942\n }\n }\n distance: 0.75\n }\n }"]]