Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
FT.CREATE erstellt einen suchbaren Index.
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): Dies ist 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-Feldname nach SCHEMA gibt den Feldnamen im Hash an. [AS alias] weist dem Attribut „Feldname“ den Alias alias zu.
Feldtypen
VECTOR (erforderlich): Vektorfeld für die Vektorsuche:
[HNSW|FLAT] (erforderlich): Ausgewiesener Algorithmus. Entweder FLAT (Brute-Force-Suche) oder HNSW (Hierarchical Navigable Small World).
attribute_count (erforderlich): Gesamtzahl der Attribute mit Namen und Werten, die in der Algorithmuskonfiguration übergeben wurden.
attribute_name attribute_value: Schlüssel/Wert-Paare, die die Indexkonfiguration definieren, aber für einen der beiden verfügbaren Algorithmen spezifisch sind.
Erforderliche Attribute für den HNSW-Algorithmus:
DIM (erforderlich): Anzahl der Vektordimensionen. Zulässige Werte sind 1–32768.
TYPE (erforderlich): Der Vektortyp. Es wird nur FLOAT32 unterstützt.
DISTANCE_METRIC (erforderlich): Muss einen der folgenden Werte haben: L2, IP oder COSINE.
Optionale Attribute für den HNSW-Algorithmus:
EF_RUNTIME (optional): Legt die Anzahl der Vektoren fest, die bei einem Abfragevorgang geprüft 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 erhöhen die Abfragezeit, verbessern aber die Abfrageerinnerung.
M (optional): Die Anzahl der maximal zulässigen ausgehenden Kanten für jeden Knoten im Graphen in jeder Ebene. Die maximale Anzahl ausgehender Kanten beträgt 2 Millionen für Schicht 0. Der Standardwert ist 16. Maximal 512.
EF_CONSTRUCTION (optional): Legt die Anzahl der Vektoren fest, die beim Erstellen des Index geprüft werden sollen. Der Standardwert ist 200 und der Höchstwert 4096. Höhere Werte erhöhen 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 Indexspeicherzuweisung.
Erforderliche FLAT-Algorithmusattribute:
DIM (erforderlich): Anzahl der Vektordimensionen.
TYPE (erforderlich): Der Vektortyp. Es wird nur FLOAT32 unterstützt.
DISTANCE_METRIC (erforderlich): Muss einen der folgenden Werte haben: L2, IP oder COSINE.
Optionale FLAT-Algorithmus-Attribute:
INITIAL_CAP (optional): Bestimmt die Startvektorkapazität des Index. Dieser Parameter bestimmt die Indexspeicherzuweisung.
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. Ein Tag-String wie „HeLLo“ wird als „hallo“ indexiert. Eine Suchanfrage nach „Hallo“ und „HeLlo“ ergibt dasselbe Ergebnis.
Hinweise
Innerhalb des Befehls „FT.CREATE“ können VEKTOR-, NUMERISCHE und TAG-Indexe in beliebiger Reihenfolge erscheinen.
Ein Feld kann nur einmal indexiert werden. Im Beispiel kann das Feld my_vector_field_key nicht innerhalb desselben Index wiederholt werden.
Mit einem einzelnen Befehl „FT.CREATE“ können maximal 10 Felder indexiert werden.
Bei TAGs wird standardmäßig nicht zwischen Groß- und Kleinschreibung unterschieden.
Standardmäßig werden TAGs durch , voneinander getrennt.
Einzelne Abfragen nach Tags und numerische Abfragen werden nicht unterstützt. Diese Felder können nur in Verbindung mit vektorbasierten Suchanfragen 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-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```"]]