SCHEMA hash_field_name (obligatorio): hash_field_name después de SCHEMA identifica el nombre del campo en el hash. [AS alias] asigna el nombre alias como alias para el atributo nombre del campo.
Tipos de campo
VECTOR (obligatorio): Es el campo de vectores para la búsqueda de vectores:
[HNSW|FLAT] (obligatorio): Es el algoritmo designado. FLAT (fuerza bruta) o HNSW (mundo pequeño navegable jerárquico).
attribute_count (obligatorio): Es el recuento total de atributos de nombres y valores que se pasan en la configuración del algoritmo.
attribute_name attribute_value: Son pares clave-valor que definen la configuración del índice, pero son específicos de uno de los dos algoritmos disponibles.
Atributos obligatorios del algoritmo HNSW:
DIM (obligatorio): Es el recuento de dimensiones del vector. Los valores aceptados son 1-32768.
TYPE (obligatorio): Es el tipo de vector. Solo se admite FLOAT32.
DISTANCE_METRIC (obligatorio): Debe ser uno de los siguientes: L2, IP o COSINE.
Atributos opcionales del algoritmo HNSW:
EF_RUNTIME (opcional): Establece el recuento de vectores que se examinarán durante una operación de consulta. El valor predeterminado es 10 y el máximo es 4096. Puedes establecer este valor de parámetro para cada consulta que ejecutes. Los valores más altos aumentan los tiempos de consulta, pero mejoran la recuperación de consultas.
M (opcional): Es el recuento de los bordes salientes máximos permitidos para cada nodo del gráfico en cada capa. La cantidad máxima de aristas salientes es de 2 millones para la capa 0. El valor predeterminado es 16. El máximo es 512.
EF_CONSTRUCTION (opcional): Establece el recuento de vectores que se examinarán durante la construcción del índice. El valor predeterminado es 200 y el máximo es 4096. Los valores más altos aumentan el tiempo necesario para crear índices, pero mejoran la proporción de recuperación.
INITIAL_CAP (opcional): Determina la capacidad del vector inicial del índice. El valor predeterminado es 1024. Este parámetro determina la asignación de memoria del índice.
Atributos obligatorios del algoritmo FLAT:
DIM (obligatorio): Es el recuento de dimensiones del vector.
TYPE (obligatorio): Es el tipo de vector. Solo se admite FLOAT32.
DISTANCE_METRIC (obligatorio): Debe ser uno de los siguientes: L2, IP o COSINE.
Atributos opcionales del algoritmo FLAT:
INITIAL_CAP (opcional): Determina la capacidad del vector inicial del índice. Este parámetro determina la asignación de memoria del índice.
NUMERIC (opcional): Es un campo numérico para la búsqueda numérica.
TAG (opcional): Es el campo de etiqueta para la búsqueda basada en etiquetas.
SEPARATOR (opcional): Es un carácter que se usa para dividir la cadena de etiquetas en etiquetas individuales. La opción predeterminada es ,. El valor especificado debe ser un carácter único. Por ejemplo, la cadena de la etiqueta "hello, world" se interpretará como "hello" y "world", y se indexará según corresponda. Los valores permitidos son ,.<>{}[]"':;!@#$%^&*()-+=~.
CASESENSITIVE (opcional): Indica si los campos de etiqueta distinguen mayúsculas de minúsculas. De forma predeterminada, las etiquetas no distinguen mayúsculas de minúsculas. Una cadena de etiquetas "HeLLo" se indexará como "hello", y una búsqueda de "Hello" y "HeLlo" arrojará el mismo resultado.
Notas
Dentro del comando FT.CREATE, los índices VECTOR, NUMERIC y TAG pueden aparecer en cualquier secuencia.
Un campo solo se puede indexar una vez. En el ejemplo proporcionado, el campo my_vector_field_key no se puede repetir dentro del mismo índice.
En un solo comando FT.CREATE, se pueden indexar un máximo de 10 campos.
De forma predeterminada, los TAG no distinguen mayúsculas de minúsculas.
De forma predeterminada, los TAG se delimitan con ,.
No se admiten consultas individuales en etiquetas ni consultas numéricas. Estos campos solo se pueden utilizar junto con búsquedas basadas en vectores.
Ejemplos
Ejemplo de HNSW:
FT.CREATE my_index_name SCHEMA my_hash_field_key VECTOR HNSW 10 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE M 4 EF_CONSTRUCTION 100
Ejemplo de FLAT:
FT.CREATE my_index_name SCHEMA my_hash_field_key VECTOR Flat 8 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE INITIAL_CAP 15000
Ejemplo de HNSW con un campo numérico:
FT.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
Ejemplo de HNSW con un campo de etiqueta:
FT.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
Ejemplo de HNSW con una etiqueta y un campo numérico:
FT.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
Ejemplo de HNSW con varios campos numéricos y de etiquetas:
FT.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
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-05 (UTC)"],[],[],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```"]]