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

[MySQL] feat(mysql): Support vectorIndex and secondaryEngineAttribute #3778

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dengfuping
Copy link

Background

vectorIndex and secondaryEngineAttribute usage

const users = mysqlTable(
    "users",
    {
      id: bigint({ mode: "bigint" }).autoincrement().primaryKey(),
      name: varchar({ length: 255 }).notNull(),
      embedding: vector("embedding", { length: 3 }),
    },
    (table) => {
      return {
        idx_embedding: vectorIndex({
          name: "idx_embedding",
          secondaryEngineAttribute: '{"type":"spann", "distance":"cosine"}',
        }).on(table.embedding),
      };
    }
  )
  • Related SQL of create index:
CREATE VECTOR INDEX `idx_embedding` ON `users` (`embedding`) SECONDARY_ENGINE_ATTRIBUTE=\'{"type":"spann", "distance":"cosine"}\';

@kravetsone
Copy link
Contributor

secondaryEngineAttribute: '{"type":"spann", "distance":"cosine"}',

Why not object?

@dengfuping
Copy link
Author

dengfuping commented Dec 16, 2024

@kravetsone

  • SECONDARY_ENGINE_ATTRIBUTE follow the type in MySQL:

image

image

@kravetsone
Copy link
Contributor

@kravetsone

  • SECONDARY_ENGINE_ATTRIBUTE follow the type defined e in MySQL:

image

image

yeah but it json

so we can use object (with type-safety) as input and serialize it to string

@dengfuping
Copy link
Author

dengfuping commented Dec 17, 2024

@kravetsone Considering that most frameworks treat secondaryEngineAttribute as string type, I think that it's more consistent to use string type.

image

image

@dengfuping dengfuping changed the title feat(mysql): Support vectorIndex and secondaryEngineAttribute [MySQL] feat(mysql): Support vectorIndex and secondaryEngineAttribute Dec 18, 2024
@dengfuping dengfuping force-pushed the support-mysql-vector-index branch from 90f433f to 62713f7 Compare December 30, 2024 09:35
@dengfuping dengfuping force-pushed the support-mysql-vector-index branch from b0d6111 to 1b55241 Compare December 30, 2024 09:42
@dengfuping dengfuping requested a review from Vinlock December 30, 2024 09:46
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