-
Notifications
You must be signed in to change notification settings - Fork 7
DOCSP-49759: Vector search index #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,7 @@ This section shows how to create the following advanced | |
index types: | ||
|
||
- :ref:`django-indexes-atlas-search` | ||
- :ref:`django-indexes-vector-search` | ||
- :ref:`django-indexes-partial` | ||
- :ref:`django-indexes-unique` | ||
|
||
|
@@ -240,6 +241,48 @@ an Atlas Search index named ``"title_search_idx"`` on the ``title`` field: | |
- `SearchIndex <{+api+}ref/models/indexes/#searchindex>`__ class in the | ||
{+django-odm+} API documentation. | ||
|
||
.. _django-indexes-vector-search: | ||
|
||
Atlas Vector Search Indexes | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Atlas Vector Search indexes allow you to query data based on its semantic meaning | ||
rather than by keyword matches. You can integrate vector search with full-text search | ||
queries and AI frameworks to support a range of use cases. | ||
|
||
To create a vector search index, assign the ``indexes`` option in your model's | ||
``Meta`` class to a ``VectorSearchIndex`` object. Pass the following arguments to the | ||
``VectorSearchIndex()`` constructor: | ||
|
||
- ``name``: *(Optional)* The name of your Atlas Vector Search index. If you do not | ||
specify this argument, {+framework+} automatically generates an index name. | ||
- ``fields``: The fields you want to index. At least one must be a vector | ||
field, represented by an array of ``FloatField`` or ``IntegerField`` values and an | ||
|
||
array size. | ||
- ``similarities``: The :atlas:`similarity function </atlas-vector-search/vector-search-type/#std-label-avs-similarity-functions>` | ||
to use. You can use the ``"cosine"``, ``"dotProduct"``, or ``"euclidean"`` | ||
similarity function. Specify the function as a single string value or a list | ||
of values that assigns functions to individual vector fields. | ||
|
||
The following example updates the ``Recipe`` model's ``Meta`` class to create | ||
a vector search index named ``"vector_search_idx"`` on the ``ratings`` vector field | ||
and the ``cook_time`` numeric field: | ||
|
||
.. literalinclude:: /includes/model-data/indexes.py | ||
:start-after: start-vector-search | ||
:end-before: end-vector-search | ||
:language: python | ||
:copyable: | ||
:emphasize-lines: 3-9 | ||
|
||
.. tip:: | ||
|
||
To learn more about Atlas Vector Search queries and indexes, see the following resources: | ||
|
||
- :atlas:`Atlas Vector Search </atlas-vector-search>` in the Atlas documentation. | ||
- `VectorSearchIndex <{+api+}ref/models/indexes//#vectorsearchindex>`__ class in the | ||
{+django-odm+} API documentation. | ||
|
||
.. _django-indexes-partial: | ||
|
||
Partial Indexes | ||
|
Uh oh!
There was an error while loading. Please reload this page.