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
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.

2 participants