feat: vectorchord (#18042)
* wip auto-detect available extensions auto-recovery, fix reindexing check use original image for ml * set probes * update image for sql checker update images for gha * cascade * fix new instance * accurate dummy vector * simplify dummy * preexisiting pg docs * handle different db name * maybe fix sql generation * revert refreshfaces sql change * redundant switch * outdated message * update docker compose files * Update docs/docs/administration/postgres-standalone.md Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * tighten range * avoid always printing "vector reindexing complete" * remove nesting * use new images * add vchord to unit tests * debug e2e image * mention 1.107.2 in startup error * support new vchord versions --------- Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { getVectorExtension } from 'src/repositories/database.repository';
|
||||
import { getCLIPModelInfo } from 'src/utils/misc';
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
const vectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
||||
|
||||
export class UsePgVectors1700713871511 implements MigrationInterface {
|
||||
name = 'UsePgVectors1700713871511';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`SET search_path TO "$user", public, vectors`);
|
||||
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS ${vectorExtension}`);
|
||||
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS ${await getVectorExtension(queryRunner)}`);
|
||||
const faceDimQuery = await queryRunner.query(`
|
||||
SELECT CARDINALITY(embedding::real[]) as dimsize
|
||||
FROM asset_faces
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { getVectorExtension } from 'src/repositories/database.repository';
|
||||
import { vectorIndexQuery } from 'src/utils/database';
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
const vectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
||||
|
||||
export class AddCLIPEmbeddingIndex1700713994428 implements MigrationInterface {
|
||||
name = 'AddCLIPEmbeddingIndex1700713994428';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const vectorExtension = await getVectorExtension(queryRunner);
|
||||
await queryRunner.query(`SET search_path TO "$user", public, vectors`);
|
||||
|
||||
await queryRunner.query(vectorIndexQuery({ vectorExtension, table: 'smart_search', indexName: 'clip_index' }));
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { getVectorExtension } from 'src/repositories/database.repository';
|
||||
import { vectorIndexQuery } from 'src/utils/database';
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
const vectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
||||
|
||||
export class AddFaceEmbeddingIndex1700714033632 implements MigrationInterface {
|
||||
name = 'AddFaceEmbeddingIndex1700714033632';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const vectorExtension = await getVectorExtension(queryRunner);
|
||||
await queryRunner.query(`SET search_path TO "$user", public, vectors`);
|
||||
|
||||
await queryRunner.query(vectorIndexQuery({ vectorExtension, table: 'asset_faces', indexName: 'face_index' }));
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { DatabaseExtension } from 'src/enum';
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { getVectorExtension } from 'src/repositories/database.repository';
|
||||
import { vectorIndexQuery } from 'src/utils/database';
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
const vectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
||||
|
||||
export class AddFaceSearchRelation1718486162779 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const vectorExtension = await getVectorExtension(queryRunner);
|
||||
if (vectorExtension === DatabaseExtension.VECTORS) {
|
||||
await queryRunner.query(`SET search_path TO "$user", public, vectors`);
|
||||
}
|
||||
@@ -48,11 +47,11 @@ export class AddFaceSearchRelation1718486162779 implements MigrationInterface {
|
||||
await queryRunner.query(`ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE vector(512)`);
|
||||
|
||||
await queryRunner.query(vectorIndexQuery({ vectorExtension, table: 'smart_search', indexName: 'clip_index' }));
|
||||
|
||||
await queryRunner.query(vectorIndexQuery({ vectorExtension, table: 'face_search', indexName: 'face_index' }));
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
const vectorExtension = await getVectorExtension(queryRunner);
|
||||
if (vectorExtension === DatabaseExtension.VECTORS) {
|
||||
await queryRunner.query(`SET search_path TO "$user", public, vectors`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user