@@ -203,6 +203,7 @@ This section shows how to create the following advanced
203
203
index types:
204
204
205
205
- :ref:`django-indexes-atlas-search`
206
+ - :ref:`django-indexes-vector-search`
206
207
- :ref:`django-indexes-partial`
207
208
- :ref:`django-indexes-unique`
208
209
@@ -240,6 +241,47 @@ an Atlas Search index named ``"title_search_idx"`` on the ``title`` field:
240
241
- `SearchIndex <{+api+}ref/models/indexes/#searchindex>`__ class in the
241
242
{+django-odm+} API documentation.
242
243
244
+ .. _django-indexes-vector-search:
245
+
246
+ Vector Search Indexes
247
+ ~~~~~~~~~~~~~~~~~~~~~
248
+
249
+ Vector Search indexes specify the behavior of an Atlas Vector Search, which allows
250
+ you to query data based on its semantic meaning rather than only keyword matches.
251
+ You can integrate vector search with full-text search queries and AI frameworks to
252
+ support a range of use cases.
253
+
254
+ To create a Vector Search index, assign the ``indexes`` option in your model's
255
+ ``Meta`` class to a ``VectorSearchIndex`` object. Pass the following arguments to the
256
+ ``VectorSearchIndex()`` constructor:
257
+
258
+ - ``name``: *(Optional)* The name of your Vector Search index. If you do not
259
+ specify this argument, {+framework+} automatically generates an index name.
260
+ - ``fields``: The fields you want to index.
261
+ - ``similarities``: The :atlas:`similarity function </atlas-vector-search/vector-search-type/#std-label-avs-similarity-functions>`
262
+ to use. You can specify the ``"cosine"``, ``"dotProduct"``, or ``"euclidean"``
263
+ similarity function, as a single string value or a list of values that assigns
264
+ different functions to individual vector fields.
265
+
266
+ The following example updates the ``Recipe`` model's ``Meta`` class to create
267
+ a Vector Search index named ``"vector_search_idx"`` on the ``ratings`` and ``cook_time``
268
+ fields:
269
+
270
+ .. literalinclude:: /includes/model-data/indexes.py
271
+ :start-after: start-vector-search
272
+ :end-before: end-vector-search
273
+ :language: python
274
+ :copyable:
275
+ :emphasize-lines: 3-9
276
+
277
+ .. tip::
278
+
279
+ To learn more about Vector Search queries and indexes, see the following resources:
280
+
281
+ - :atlas:`Atlas Vector Search </atlas-vector-search>` in the Atlas documentation.
282
+ - `VectorSearchIndex <{+api+}ref/models/indexes//#vectorsearchindex>`__ class in the
283
+ {+django-odm+} API documentation.
284
+
243
285
.. _django-indexes-partial:
244
286
245
287
Partial Indexes
0 commit comments