Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
FT.CREATE erstellt einen durchsuchbaren Index. Bei Memorystore for Redis Cluster werden Indexe auf Clusterebene erstellt. Wenn Sie einen Index auf einem beliebigen Knoten erstellen, wird der Index auf allen Knoten im Cluster erstellt.
Syntax
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 (erforderlich): Der Name, den Sie Ihrem Index geben. Wenn bereits ein Index mit demselben Namen vorhanden ist, wird ein Fehler zurückgegeben.
ON HASH (optional): Gibt den HASH-Datentyp an. Nur der Datentyp HASH wird unterstützt.
PREFIX [count] [prefix] (optional): Gibt an, welche Hash-Schlüssel indexiert werden sollen.
SCHEMA hash_field_name (erforderlich): Der hash_field_name nach SCHEMA gibt den Feldnamen im Hash an. Mit [AS alias] wird der Name alias als Alias für das Attribut „Feldname“ zugewiesen.
Feldtypen
VECTOR (erforderlich): Vektorfeld für die Vektorsuche:
[HNSW|FLAT] (erforderlich): Der angegebene Algorithmus. Entweder FLAT (Brute Force) oder HNSW (Hierarchical Navigable Small World).
attribute_count (erforderlich): Gesamtzahl der Attribute von Namen und Werten, die in der Algorithmuskonfiguration übergeben werden.
attribute_name attribute_value: Schlüssel/Wert-Paare, die die Indexkonfiguration definieren, aber spezifisch für einen der beiden verfügbaren Algorithmen sind.
Erforderliche HNSW-Algorithmusattribute:
DIM (erforderlich): Anzahl der Vektordimensionen. Zulässige Werte sind 1–32768.
TYPE (erforderlich): Der Vektortyp. Nur FLOAT32 wird unterstützt.
DISTANCE_METRIC (erforderlich): Muss einer der folgenden Werte sein: L2, IP oder COSINE.
Optionale HNSW-Algorithmusattribute:
EF_RUNTIME (optional): Legt die Anzahl der Vektoren fest, die während eines Abfragevorgangs untersucht werden sollen. Der Standardwert ist 10 und der Höchstwert 4096. Sie können diesen Parameterwert für jede ausgeführte Abfrage festlegen. Höhere Werte verlängern die Abfragezeiten, verbessern aber den Recall.
M (optional): Die Anzahl der maximal zulässigen ausgehenden Kanten für jeden Knoten im Diagramm in jeder Ebene. Die maximale Anzahl ausgehender Kanten beträgt für Ebene 0 2 Millionen. Der Standardwert ist 16. Der Maximalwert beträgt 512.
EF_CONSTRUCTION (optional): Legt die Anzahl der Vektoren fest, die während der Indexerstellung untersucht werden sollen. Der Standardwert ist 200 und der Höchstwert 4096. Höhere Werte verlängern die Zeit, die zum Erstellen von Indexen benötigt wird, verbessern aber das Recall-Verhältnis.
INITIAL_CAP (optional): Bestimmt die Startvektorkapazität des Index. Der Standardwert ist 1024. Dieser Parameter bestimmt die Zuweisung des Indexspeichers.
Erforderliche Attribute für den FLAT-Algorithmus:
DIM (erforderlich): Anzahl der Vektordimensionen.
TYPE (erforderlich): Der Vektortyp. Nur FLOAT32 wird unterstützt.
DISTANCE_METRIC (erforderlich): Muss einer der folgenden Werte sein: L2, IP oder COSINE.
Optionale Attribute für den FLAT-Algorithmus:
INITIAL_CAP (optional): Bestimmt die Startvektorkapazität des Index. Dieser Parameter bestimmt die Zuweisung des Indexspeichers.
NUMERIC (optional): Numerisches Feld für die numerische Suche.
TAG (optional): Tag-Feld für die TAG-basierte Suche.
SEPARATOR (optional): Ein Zeichen, mit dem der Tag-String in einzelne Tags unterteilt wird. Die Standardoption ist ,. Der angegebene Wert muss ein einzelnes Zeichen sein. Der Tag-String „Hallo, Welt“ wird beispielsweise als „Hallo“ und „Welt“ interpretiert und entsprechend indexiert. Zulässige Werte sind ,.<>{}[]"':;!@#$%^&*()-+=~.
CASESENSITIVE (optional): Gibt an, ob bei Tag-Feldern zwischen Groß- und Kleinschreibung unterschieden wird. Standardmäßig wird bei Tags nicht zwischen Groß- und Kleinschreibung unterschieden. Der Tag-String „HeLLo“ wird als „hello“ indexiert. Eine Suche nach „Hello“ und „HeLlo“ liefert dasselbe Ergebnis.
Hinweise
Im Befehl FT.CREATE können VECTOR-, NUMERIC- und TAG-Indizes in beliebiger Reihenfolge angegeben werden.
Ein Feld kann nur einmal indexiert werden. Im angegebenen Beispiel kann das Feld my_vector_field_key nicht innerhalb desselben Index wiederholt werden.
In einem einzelnen FT.CREATE-Befehl können maximal 10 Felder indexiert werden.
Standardmäßig wird bei TAGs nicht zwischen Groß- und Kleinschreibung unterschieden.
Standardmäßig werden TAGs durch , getrennt.
Einzelne Anfragen zu Tags und numerische Anfragen werden nicht unterstützt. Diese Felder können nur zusammen mit vektorbasierter Suche verwendet werden.
Beispiele
HNSW-Beispiel:
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
Beispiel für 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-Beispiel mit einem numerischen Feld:
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-Beispiel mit einem Tag-Feld:
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-Beispiel mit einem Tag und einem numerischen Feld:
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-Beispiel mit mehreren Tag- und numerischen Feldern:
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
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-10 (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```"]]