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