View a markdown version of this page

Propriété de l'index : nom - Amazon DocumentDB

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

Propriété de l'index : nom

Types d'index pris en charge

Option 3.6 4.0 5.0 8.0 Cluster élastique
champ unique Oui Oui Oui Oui Oui
compound Oui Oui Oui Oui Oui
touches multiples Oui Oui Oui Oui Oui
text Non Non Oui Oui Non
géospatial Oui Oui Oui Oui Oui
vector Non Non Oui Oui Non

Utilisez l'option name pour donner un nom facultatif à l'index.

Tous les exemples utilisent le document d'exemple suivant :

{ "productId": "PROD133726", "sku": "SKU24224", "name": "Basic Printer", "manufacturer": "The Manufacturer", "tags": [ "printer", "basic", "electronics", "business" ], "barcodes": [ "542364671", "886330670", "437445606" ], "reviews": [ { "review_date": ISODate('2024-01-19T21:37:10.585Z'), ... } ], "material": "Polycarbonate", "color": "Space Gray", "supplier": { "supplierId": "SUP4", "location": { "type": "Point", "coordinates": [ -71.0589, 42.3601 ] } }, "productEmbedding": [ -0.019320633663838058, 0.019672111388113596 ], "lastUpdated": ISODate('2025-10-20T21:37:10.585Z') }

Champ unique

db.collection.createIndex( { "productId": 1 }, { "name": "single_field_index" } )

Composé

db.collection.createIndex( { "productId": 1, "manufacturer": 1 }, { "name": "compound_index" } )

Multi-key

db.collection.createIndex( { "tags": 1 }, { "name": "multikey_index" } )

Texte

db.collection.createIndex( { "name": "text" }, { "name": "text_index" } )

Géospatial

db.collection.createIndex( { "supplier.location": "2dsphere" }, { "name": "geospatial_index" } )

Vecteur

db.runCommand({ "createIndexes": "collection", "indexes": [{ "key": { "productEmbedding": "vector" }, "name": "hnsw_index", "vectorOptions": { "type": "hnsw", "dimensions": 2, "similarity": "euclidean", "m": 16, "efConstruction": 64 } }] })