Skip to content
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

Support building vector index with django_tidb>=5.0.1 #64

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Oct 23, 2024

Depends on the django-tidb update: pingcap/django-tidb#67

Update the example of using django with vector-index:

  • examples/orm-django-quickstart

Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang
Copy link
Contributor Author

/cc @wd0517 @Mini256 @breezewish

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest looks good!

embedding = VectorField(dimensions=3, db_comment="hnsw(distance=cosine)")
class Meta:
indexes = [
VectorIndex(L2Distance("embedding"), name='idx_l2'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to omit the name?

Copy link
Contributor Author

@JaySon-Huang JaySon-Huang Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, according to the django.db.models.Index, the user must set the name for an expression index in django
https://github.com/django/django/blob/69bf08e3a32492998871eb91ad84b3c8d8117180/django/db/models/indexes.py#L47-L48

Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang changed the title Support building vector index with django_tidb Support building vector index with django_tidb>=5.0.1 Nov 5, 2024
@JaySon-Huang
Copy link
Contributor Author

@wd0517 PTAL

@wd0517 wd0517 merged commit d34d3b9 into pingcap:main Nov 5, 2024
2 checks passed
@JaySon-Huang JaySon-Huang deleted the django_tidb branch November 5, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants