FT.CREATE는 검색 가능한 색인을 만듭니다. Memorystore for Redis Cluster를 사용하면 색인이 클러스터 수준에서 생성됩니다. 노드에서 색인을 만들면 클러스터의 모든 노드에 색인이 생성됩니다.
구문
FT.CREATE index
ON HASH
[PREFIX count prefix [prefix ...]]
SCHEMA field_name [AS alias] VECTOR [HNSW|FLAT] attribute_count [attribute_name attribute_value]
[field_name [AS alias] NUMERIC]
[field_name [AS alias] TAG [SEPARATOR ...] [CASESENSITIVE]]
index(필수): 색인에 지정하는 이름입니다. 이름이 같은 색인이 이미 있으면 오류가 반환됩니다.
ON HASH(선택사항): HASH 데이터 유형을 나타냅니다. HASH 데이터 유형만 지원됩니다.
PREFIX [count] [prefix](선택사항): 색인을 생성할 해시 키를 나타냅니다.
SCHEMA hash_field_name(필수): SCHEMA 다음의 hash_field_name은 해시에서 필드 이름을 식별합니다. [AS alias]는 alias 이름을 필드 이름 속성의 별칭으로 할당합니다.
필드 유형
VECTOR(필수): 벡터 검색을 위한 벡터 필드입니다.
[HNSW|FLAT](필수): 지정된 알고리즘입니다. FLAT(무차별 대입) 또는 HNSW(Hierarchical Navigable Small World)입니다.
attribute_count(필수): 알고리즘 구성에 전달된 이름과 값의 총 속성 수입니다.
attribute_name attribute_value: 색인 구성을 정의하지만 사용 가능한 두 가지 알고리즘 중 하나와 관련된 키-값 쌍입니다.
필수 HNSW 알고리즘 속성은 다음과 같습니다.
DIM(필수): 벡터 측정기준 수입니다. 허용되는 값은 1~32768입니다.
TYPE(필수): 벡터 유형입니다. FLOAT32만 지원됩니다.
DISTANCE_METRIC(필수): L2, IP, COSINE 중 하나여야 합니다.
선택적 HNSW 알고리즘 속성은 다음과 같습니다.
EF_RUNTIME(선택사항): 쿼리 작업 중에 검사할 벡터 수를 설정합니다. 기본값은 10이고 최댓값은 4096입니다. 실행하는 쿼리마다 이 매개변수 값을 설정할 수 있습니다. 값이 클수록 쿼리 시간이 늘어나지만 쿼리 재현율이 향상됩니다.
M(선택사항): 각 레이어의 그래프에 있는 노드마다 허용되는 최대 발신 에지 수입니다. 레이어 0의 최대 발신 에지 수는 2,000,000입니다. 기본값은 16입니다. 최댓값은 512입니다.
EF_CONSTRUCTION(선택사항): 색인 생성 중에 검사할 벡터 수를 설정합니다. 기본값은 200이고 최댓값은 4096입니다. 값이 클수록 색인을 만드는 데 필요한 시간이 늘어나지만 재현율 비율이 향상됩니다.
INITIAL_CAP(선택사항): 색인의 시작 벡터 용량을 결정합니다. 기본값은 1024입니다. 이 매개변수는 색인 메모리 할당을 결정합니다.
필수 FLAT 알고리즘 속성은 다음과 같습니다.
DIM(필수): 벡터 측정기준 수입니다.
TYPE(필수): 벡터 유형입니다. FLOAT32만 지원됩니다.
DISTANCE_METRIC(필수): L2, IP, COSINE 중 하나여야 합니다.
선택적 FLAT 알고리즘 속성은 다음과 같습니다.
INITIAL_CAP(선택사항): 색인의 시작 벡터 용량을 결정합니다. 이 매개변수는 색인 메모리 할당을 결정합니다.
NUMERIC(선택사항): 숫자 검색을 위한 숫자 필드입니다.
TAG(선택사항): 태그 기반 검색을 위한 태그 필드입니다.
SEPARATOR(선택사항): 태그 문자열을 개별 태그로 나누는 데 사용되는 문자입니다. 기본 옵션은 ,입니다. 지정된 값은 단일 문자여야 합니다. 예를 들어 태그 문자열 'hello, world'는 'hello' 및 'world'로 해석되어 적절하게 색인이 생성됩니다. 허용되는 값은 ,.<>{}[]"':;!@#$%^&*()-+=~입니다.
CASESENSITIVE(선택사항): 태그 필드의 대소문자 구분을 나타냅니다. 기본적으로 태그는 대소문자를 구분하지 않습니다. 태그 문자열 'HeLLo'는 'hello'로 색인이 생성되며 'Hello' 및 'HeLlo' 쿼리는 동일한 결과를 가져옵니다.
참고
FT.CREATE 명령어 내에서 벡터, 숫자, 태그 색인은 어떤 순서로든 표시될 수 있습니다.
필드는 한 번만 색인을 생성할 수 있습니다. 제공된 예시에서 my_vector_field_key 필드는 동일한 색인 내에 반복될 수 없습니다.
단일 FT.CREATE 명령어에서 최대 10개의 필드에 색인을 생성할 수 있습니다.
기본적으로 태그는 대소문자를 구분하지 않습니다.
기본적으로 태그는 ,으로 구분됩니다.
태그 및 숫자 쿼리의 개별 쿼리는 지원되지 않습니다. 이 필드는 벡터 기반 검색과 함께만 사용할 수 있습니다.
예시
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
FLAT 예시는 다음과 같습니다.
FT.CREATE my_index_name SCHEMA my_hash_field_key VECTOR Flat 8 TYPE FLOAT32 DIM 20 DISTANCE_METRIC COSINE INITIAL_CAP 15000
숫자 필드가 있는 HNSW 예시는 다음과 같습니다.
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
태그 필드가 있는 HNSW 예시는 다음과 같습니다.
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
태그와 숫자 필드가 있는 HNSW 예시는 다음과 같습니다.
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
태그 및 숫자 필드가 여러 개인 HNSW 예시는 다음과 같습니다.
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
[[["이해하기 쉬움","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(UTC)"],[],[],null,["# FT.CREATE\n\n`FT.CREATE` creates a searchable index. With Memorystore for Redis Cluster, indexes are created at the cluster level. Creating an index on any node will cause creation of the index across all nodes in the cluster.\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```"]]