[[["容易理解","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 (世界標準時間)。"],[],[],null,["# FT.CREATE\n\n`FT.CREATE` creates a searchable index.\n\nSyntax\n------\n\n```\nFT.CREATE index\n ON HASH\n [PREFIX count prefix [prefix ...]]\n SCHEMA field_name [AS alias] VECTOR [HNSW|FLAT] attribute_count [attribute_name attribute_value]\n [field_name [AS alias] NUMERIC]\n [field_name [AS alias] TAG [SEPARATOR ...] [CASESENSITIVE]]\n```\n\n- `index` (required): This is the name you give to your index. If an index with the same\n name exists already, an error is returned.\n\n- `ON HASH` (optional): This indicates the HASH data type. Only the HASH data type is\n supported.\n\n- `PREFIX [count] [prefix]` (optional): This indicates which hash keys to index.\n\n- `SCHEMA hash_field_name` (required): The hash_field_name after SCHEMA identifies the field name\n in the hash. `[AS alias]` assigns the name `alias` as an alias for the\n field name attribute.\n\n### Field types\n\n- `VECTOR` (required): Vector field for vector search:\n\n - `[HNSW|FLAT]` (required): Designated algorithm. Either `FLAT` (brute force) or\n HNSW (Hierarchical Navigable Small World).\n\n - `attribute_count` (required): Total attribute count of names and values\n passed in the algorithm config.\n\n - `attribute_name attribute_value`: Key-value pairs that define\n the index configuration, but are specific to one of the two available\n algorithms.\n\n - Required HNSW algorithm attributes:\n\n - `DIM` (required): Vector dimensions count. Accepted values are `1`-`32768`.\n\n - `TYPE` (required): The vector type. Only `FLOAT32` is supported.\n\n - `DISTANCE_METRIC` (required): Must be one of the following - `L2`, `IP`, or `COSINE`.\n\n - Optional HNSW algorithm attributes:\n\n - `EF_RUNTIME` (optional): Sets the count of vectors to be examined during a query operation. The default is `10`, and the max is `4096`. You can set this parameter value for each query you run. Higher values increase query times, but improve query recall.\n\n - `M` (optional): The count of maximum permitted outgoing edges for each node in the graph in each layer. The maximum number of outgoing edges is 2M for layer 0. The Default is 16. The maximum is 512.\n\n - `EF_CONSTRUCTION` (optional): Sets count for vectors to be examined during index construction. The default is `200`, and the max is `4096`. Higher values increase the time needed to create indexes, but improve the recall ratio.\n\n - `INITIAL_CAP` (optional): Determines the starting vector capacity of the index. The default is `1024`. This parameter determines the index memory allocation.\n\n - Required FLAT algorithm attributes:\n\n - `DIM` (required): Vector dimensions count.\n\n - `TYPE` (required): The vector type. Only `FLOAT32` is supported.\n\n - `DISTANCE_METRIC` (required): Must be one of the following - `L2`, `IP`, or `COSINE`.\n\n - Optional FLAT algorithm attributes:\n\n - `INITIAL_CAP` (optional): Determines the starting vector capacity of the index. This parameter determines the index memory allocation.\n- `NUMERIC` (optional) - Numeric field for numeric search.\n\n- `TAG` (optional) - Tag field for TAG based search.\n\n - `SEPARATOR` (optional): A character utilized to divide the tag string into individual tags. The default option is `,`. The specified value must be a singular character. For example, the tag string \"hello, world\" will be interpreted as \"hello\" and \"world\" and will be indexed accordingly. Allowed values are `,.\u003c\u003e{}[]\"':;!@#$%^&*()-+=~`\n\n - `CASESENSITIVE` (optional): Denotes the case sensitivity of tag fields. By default, tags are not case-sensitive. A tag string \"HeLLo\" will be indexed as \"hello,\" and a query for \"Hello\" and \"HeLlo\" will yield the same result.\n\n### Notes\n\n- Within the FT.CREATE command, VECTOR, NUMERIC, and TAG indexes can appear in any sequence.\n\n- A field can only be indexed once. In the example provided, the field `my_vector_field_key` cannot be repeated within the same index.\n\n- In a single FT.CREATE command, a maximum of 10 fields can be indexed.\n\n- By default, TAGs are case insensitive.\n\n- By default, TAGs are delimited by `,`.\n\n- Individual queries on tag and numeric queries are not supported. These fields can only be utilized along with vector-based searches.\n\n### Examples\n\nHNSW example: \n\n```\nFT.CREATE my_index_name SCHEMA my_hash_field_key VECTOR HNSW 10 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE M 4 EF_CONSTRUCTION 100\n```\n\nFLAT example: \n\n```\nFT.CREATE my_index_name SCHEMA my_hash_field_key VECTOR Flat 8 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE INITIAL_CAP 15000\n```\n\nHNSW example with a numeric field: \n\n```\nFT.CREATE my_index_name SCHEMA my_vector_field_key VECTOR HNSW 10 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE M 4 EF_CONSTRUCTION 100 my_numeric_field_key NUMERIC\n```\n\nHNSW example with a tag field: \n\n```\nFT.CREATE my_index_name SCHEMA my_vector_field_key VECTOR HNSW 10 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE M 4 EF_CONSTRUCTION 100 my_tag_field_key TAG SEPARATOR '@' CASESENSITIVE \n```\n\nHNSW example with a tag and a numeric field: \n\n```\nFT.CREATE my_index_name SCHEMA my_vector_field_key VECTOR HNSW 10 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE M 4 EF_CONSTRUCTION 100 my_tag_field_key TAG SEPARATOR '@' CASESENSITIVE my_numeric_field_key NUMERIC\n```\n\nHNSW example with multiple tag and numeric fields: \n\n```\nFT.CREATE my_index_name SCHEMA my_vector_field_key VECTOR HNSW 10 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE M 4 EF_CONSTRUCTION 100 my_tag_field_key_1 TAG SEPARATOR '@' CASESENSITIVE my_numeric_field_key_1 NUMERIC my_numeric_field_key_2 NUMERIC my_tag_field_key_2 TAG\n```"]]