refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
1 parent
9097ee699d
commit
9058149576
3136 files changed
+18018
-18004
No files matched your search
@@ -8,7 +8,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
const envDorisCompatMode = "DORIS_COMPAT_MODE"
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestMoveIndicesLegacyUpdatesOnlyExactSourceDocument(t *testing.T) {
|
||||
repo, mock, _, cleanup := newTestRepo(t)
|
||||
defer cleanup()
|
||||
primeCompatMode(repo, dorisCompatModeLegacy, nil)
|
||||
mock.ExpectExec("UPDATE `weknora_embeddings_2` SET knowledge_base_id = \\?, tag_id = '' WHERE "+
|
||||
mock.ExpectExec("UPDATE `academy_embeddings_2` SET knowledge_base_id = \\?, tag_id = '' WHERE "+
|
||||
"knowledge_base_id = \\? AND knowledge_id = \\?").
|
||||
WithArgs("target", "source", "doc").
|
||||
WillReturnResult(sqlmock.NewResult(0, 3))
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// 字段名常量。Doris 是 SQL 库,字段名要在 SELECT/WHERE/INSERT 多处复用,
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultTableBaseName = "weknora_embeddings"
|
||||
defaultTableBaseName = "academy_embeddings"
|
||||
envDorisTablePrefix = "DORIS_TABLE_PREFIX"
|
||||
)
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/types"
|
||||
secutils "academy/internal/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -54,8 +54,8 @@ func newTestRepo(t *testing.T) (*dorisRepository, sqlmock.Sqlmock, *httptest.Ser
|
||||
feHTTPBase: srv.URL,
|
||||
username: "u",
|
||||
password: "p",
|
||||
database: "weknora",
|
||||
tableBaseName: "weknora_embeddings",
|
||||
database: "academy",
|
||||
tableBaseName: "academy_embeddings",
|
||||
}
|
||||
|
||||
cleanup := func() {
|
||||
@@ -196,11 +196,11 @@ func TestPartialUpdateRows_HappyPath(t *testing.T) {
|
||||
{"id": "id2", "is_enabled": false},
|
||||
}
|
||||
require.NoError(t, repo.partialUpdateRows(context.Background(),
|
||||
"weknora_embeddings_768", []string{"id", "is_enabled"}, rows))
|
||||
"academy_embeddings_768", []string{"id", "is_enabled"}, rows))
|
||||
|
||||
require.NotNil(t, captured)
|
||||
assert.Equal(t, http.MethodPut, captured.Method)
|
||||
assert.Equal(t, "/api/weknora/weknora_embeddings_768/_stream_load", captured.URL.Path)
|
||||
assert.Equal(t, "/api/academy/academy_embeddings_768/_stream_load", captured.URL.Path)
|
||||
|
||||
assert.Equal(t, "true", captured.Header.Get("partial_columns"))
|
||||
assert.Equal(t, "true", captured.Header.Get("strip_outer_array"))
|
||||
@@ -348,7 +348,7 @@ func TestDeleteByChunkIDList_SQLShape(t *testing.T) {
|
||||
repo, mock, _, cleanup := newTestRepo(t)
|
||||
defer cleanup()
|
||||
|
||||
mock.ExpectExec(`DELETE FROM .*weknora_embeddings_768.* WHERE chunk_id IN \(\?, \?\)`).
|
||||
mock.ExpectExec(`DELETE FROM .*academy_embeddings_768.* WHERE chunk_id IN \(\?, \?\)`).
|
||||
WithArgs("c1", "c2").
|
||||
WillReturnResult(sqlmock.NewResult(0, 2))
|
||||
|
||||
@@ -371,7 +371,7 @@ func TestVectorRetrieve_SQLShape(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings_3").
|
||||
WithArgs("academy", "academy_embeddings_3").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(1))
|
||||
|
||||
// Doris does not support placeholders for LIMIT, so TopK is inlined as a
|
||||
@@ -406,7 +406,7 @@ func TestVectorRetrieve_SQLShape_LegacyMode(t *testing.T) {
|
||||
primeCompatMode(repo, dorisCompatModeLegacy, nil)
|
||||
|
||||
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings_3").
|
||||
WithArgs("academy", "academy_embeddings_3").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(1))
|
||||
|
||||
mock.ExpectQuery(`SELECT id, content, .*cosine_distance_approximate.*HAVING score >= \? ORDER BY score DESC LIMIT \d+`).
|
||||
@@ -452,9 +452,9 @@ func TestKeywordsRetrieve_SQLShape(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings\\_%").
|
||||
WithArgs("academy", "academy_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).
|
||||
AddRow("weknora_embeddings_768"))
|
||||
AddRow("academy_embeddings_768"))
|
||||
|
||||
// LIMIT is inlined (see VectorRetrieve), so only is_enabled and the
|
||||
// MATCH_ANY query string are bound arguments.
|
||||
@@ -488,25 +488,25 @@ func TestBatchUpdateChunkEnabledStatus_RewritesRows(t *testing.T) {
|
||||
|
||||
repo := &dorisRepository{
|
||||
db: db,
|
||||
database: "weknora",
|
||||
tableBaseName: "weknora_embeddings",
|
||||
database: "academy",
|
||||
tableBaseName: "academy_embeddings",
|
||||
}
|
||||
primeCompatMode(repo, dorisCompatModeInnerProductDuplicate, nil)
|
||||
|
||||
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("weknora_embeddings_768"))
|
||||
mock.ExpectQuery(`SELECT id, content, source_id, source_type, chunk_id, knowledge_id, knowledge_base_id, tag_id, is_enabled, embedding FROM .*weknora_embeddings_768.* WHERE chunk_id IN`).
|
||||
WithArgs("academy", "academy_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("academy_embeddings_768"))
|
||||
mock.ExpectQuery(`SELECT id, content, source_id, source_type, chunk_id, knowledge_id, knowledge_base_id, tag_id, is_enabled, embedding FROM .*academy_embeddings_768.* WHERE chunk_id IN`).
|
||||
WithArgs("c1").
|
||||
WillReturnRows(sqlmock.NewRows([]string{
|
||||
"id", "content", "source_id", "source_type",
|
||||
"chunk_id", "knowledge_id", "knowledge_base_id", "tag_id",
|
||||
"is_enabled", "embedding",
|
||||
}).AddRow("row-1", "hello", "src1", 0, "c1", "k1", "kb1", "t1", true, "[1,2,3]"))
|
||||
mock.ExpectExec(`DELETE FROM .*weknora_embeddings_768.* WHERE id IN \(\?\)`).
|
||||
mock.ExpectExec(`DELETE FROM .*academy_embeddings_768.* WHERE id IN \(\?\)`).
|
||||
WithArgs("row-1").
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
mock.ExpectExec(`INSERT INTO .*weknora_embeddings_768.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
|
||||
mock.ExpectExec(`INSERT INTO .*academy_embeddings_768.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
|
||||
WithArgs("row-1", "hello", "src1", 0, "c1", "k1", "kb1", "t1", false).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
|
||||
@@ -521,9 +521,9 @@ func TestBatchUpdateChunkEnabledStatus_LegacyModeUsesPartialUpdate(t *testing.T)
|
||||
primeCompatMode(repo, dorisCompatModeLegacy, nil)
|
||||
|
||||
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("weknora_embeddings_768"))
|
||||
mock.ExpectQuery(`SELECT id, chunk_id FROM .*weknora_embeddings_768.* WHERE chunk_id IN`).
|
||||
WithArgs("academy", "academy_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("academy_embeddings_768"))
|
||||
mock.ExpectQuery(`SELECT id, chunk_id FROM .*academy_embeddings_768.* WHERE chunk_id IN`).
|
||||
WithArgs("c1").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "chunk_id"}).AddRow("row-1", "c1"))
|
||||
|
||||
@@ -539,8 +539,8 @@ func TestEnsureTable_DDLShape(t *testing.T) {
|
||||
|
||||
repo := &dorisRepository{
|
||||
db: db,
|
||||
database: "weknora",
|
||||
tableBaseName: "weknora_embeddings",
|
||||
database: "academy",
|
||||
tableBaseName: "academy_embeddings",
|
||||
bucketsNum: 5,
|
||||
replicationNum: 2,
|
||||
}
|
||||
@@ -548,16 +548,16 @@ func TestEnsureTable_DDLShape(t *testing.T) {
|
||||
|
||||
// 表不存在
|
||||
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings_768").
|
||||
WithArgs("academy", "academy_embeddings_768").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(0))
|
||||
// CREATE TABLE 应包含关键属性和 Doris 支持的 inner_product ANN metric
|
||||
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*weknora_embeddings_768.*metric_type"="inner_product".*DUPLICATE KEY\(id\).*BUCKETS 5.*replication_num.*=.*2`).
|
||||
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*academy_embeddings_768.*metric_type"="inner_product".*DUPLICATE KEY\(id\).*BUCKETS 5.*replication_num.*=.*2`).
|
||||
WillReturnResult(sqlmock.NewResult(0, 0))
|
||||
// SHOW INDEX 一次即返回 ANN 已 FINISHED
|
||||
mock.ExpectQuery(`SHOW INDEX FROM .*weknora_embeddings_768.*`).
|
||||
mock.ExpectQuery(`SHOW INDEX FROM .*academy_embeddings_768.*`).
|
||||
WillReturnRows(
|
||||
sqlmock.NewRows([]string{"Table", "Key_name", "State"}).
|
||||
AddRow("weknora_embeddings_768", "idx_emb", "FINISHED"),
|
||||
AddRow("academy_embeddings_768", "idx_emb", "FINISHED"),
|
||||
)
|
||||
|
||||
require.NoError(t, repo.ensureTable(context.Background(), 768))
|
||||
@@ -574,22 +574,22 @@ func TestEnsureTable_DDLShape_LegacyMode(t *testing.T) {
|
||||
|
||||
repo := &dorisRepository{
|
||||
db: db,
|
||||
database: "weknora",
|
||||
tableBaseName: "weknora_embeddings",
|
||||
database: "academy",
|
||||
tableBaseName: "academy_embeddings",
|
||||
bucketsNum: 5,
|
||||
replicationNum: 2,
|
||||
}
|
||||
primeCompatMode(repo, dorisCompatModeLegacy, nil)
|
||||
|
||||
mock.ExpectQuery(`SELECT COUNT\(1\) FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings_768").
|
||||
WithArgs("academy", "academy_embeddings_768").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"c"}).AddRow(0))
|
||||
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*weknora_embeddings_768.*metric_type"="cosine_distance".*UNIQUE KEY\(id\).*enable_unique_key_merge_on_write.*true`).
|
||||
mock.ExpectExec(`CREATE TABLE IF NOT EXISTS .*academy_embeddings_768.*metric_type"="cosine_distance".*UNIQUE KEY\(id\).*enable_unique_key_merge_on_write.*true`).
|
||||
WillReturnResult(sqlmock.NewResult(0, 0))
|
||||
mock.ExpectQuery(`SHOW INDEX FROM .*weknora_embeddings_768.*`).
|
||||
mock.ExpectQuery(`SHOW INDEX FROM .*academy_embeddings_768.*`).
|
||||
WillReturnRows(
|
||||
sqlmock.NewRows([]string{"Table", "Key_name", "State"}).
|
||||
AddRow("weknora_embeddings_768", "idx_emb", "FINISHED"),
|
||||
AddRow("academy_embeddings_768", "idx_emb", "FINISHED"),
|
||||
)
|
||||
|
||||
require.NoError(t, repo.ensureTable(context.Background(), 768))
|
||||
@@ -605,16 +605,16 @@ func TestBatchSave_SQLShape(t *testing.T) {
|
||||
|
||||
repo := &dorisRepository{
|
||||
db: db,
|
||||
database: "weknora",
|
||||
tableBaseName: "weknora_embeddings",
|
||||
database: "academy",
|
||||
tableBaseName: "academy_embeddings",
|
||||
}
|
||||
primeCompatMode(repo, dorisCompatModeInnerProductDuplicate, nil)
|
||||
repo.initializedTables.Store(3, true) // 跳过 ensureTable
|
||||
|
||||
mock.ExpectExec(`DELETE FROM .*weknora_embeddings_3.* WHERE id IN \(\?\)`).
|
||||
mock.ExpectExec(`DELETE FROM .*academy_embeddings_3.* WHERE id IN \(\?\)`).
|
||||
WithArgs("src1").
|
||||
WillReturnResult(sqlmock.NewResult(0, 0))
|
||||
mock.ExpectExec(`INSERT INTO .*weknora_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
|
||||
mock.ExpectExec(`INSERT INTO .*academy_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
|
||||
WithArgs(
|
||||
"src1", "hello", "src1", 0,
|
||||
"c1", "k1", "kb1", "",
|
||||
@@ -648,13 +648,13 @@ func TestBatchSave_SQLShape_LegacyMode(t *testing.T) {
|
||||
|
||||
repo := &dorisRepository{
|
||||
db: db,
|
||||
database: "weknora",
|
||||
tableBaseName: "weknora_embeddings",
|
||||
database: "academy",
|
||||
tableBaseName: "academy_embeddings",
|
||||
}
|
||||
primeCompatMode(repo, dorisCompatModeLegacy, nil)
|
||||
repo.initializedTables.Store(3, true)
|
||||
|
||||
mock.ExpectExec(`INSERT INTO .*weknora_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
|
||||
mock.ExpectExec(`INSERT INTO .*academy_embeddings_3.*VALUES \(\?, \?, \?, \?, \?, \?, \?, \?, \?, \[`).
|
||||
WithArgs(
|
||||
"src1", "hello", "src1", 0,
|
||||
"c1", "k1", "kb1", "",
|
||||
@@ -687,17 +687,17 @@ func TestResolveCompatMode_RejectsExistingModeSwitch(t *testing.T) {
|
||||
repo.compatModeRequested = dorisCompatModeLegacy
|
||||
|
||||
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("weknora_embeddings_768"))
|
||||
mock.ExpectQuery(`SHOW CREATE TABLE .*weknora_embeddings_768.*`).
|
||||
WithArgs("academy", "academy_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}).AddRow("academy_embeddings_768"))
|
||||
mock.ExpectQuery(`SHOW CREATE TABLE .*academy_embeddings_768.*`).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"Table", "Create Table"}).AddRow(
|
||||
"weknora_embeddings_768",
|
||||
"CREATE TABLE `weknora_embeddings_768` (id VARCHAR(64)) ENGINE=OLAP DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 10 PROPERTIES(\"replication_num\"=\"1\")",
|
||||
"academy_embeddings_768",
|
||||
"CREATE TABLE `academy_embeddings_768` (id VARCHAR(64)) ENGINE=OLAP DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 10 PROPERTIES(\"replication_num\"=\"1\")",
|
||||
))
|
||||
|
||||
_, err := repo.resolveCompatMode(context.Background())
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "not interchangeable after weknora_embeddings_*")
|
||||
assert.Contains(t, err.Error(), "not interchangeable after academy_embeddings_*")
|
||||
assert.Contains(t, err.Error(), string(dorisCompatModeInnerProductDuplicate))
|
||||
assert.NoError(t, mock.ExpectationsWereMet())
|
||||
}
|
||||
@@ -708,7 +708,7 @@ func TestResolveCompatMode_AutoPrefersInnerProductDuplicate(t *testing.T) {
|
||||
repo.compatModeRequested = dorisCompatModeAuto
|
||||
|
||||
mock.ExpectQuery(`SELECT TABLE_NAME FROM information_schema.tables`).
|
||||
WithArgs("weknora", "weknora_embeddings\\_%").
|
||||
WithArgs("academy", "academy_embeddings\\_%").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"TABLE_NAME"}))
|
||||
mock.ExpectQuery(`SELECT inner_product_approximate\(\[1.0\],\[1.0\]\)`).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"v"}).AddRow(1.0))
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
// 默认的桶数 / 副本数。Doris 在 PROPERTIES 不指定时会用集群默认值,
|
||||
@@ -126,7 +126,7 @@ func (r *dorisRepository) createTable(ctx context.Context, tableName string, dim
|
||||
//
|
||||
// 关键点:
|
||||
// - DUPLICATE KEY(id):兼容当前 Doris/SelectDB 对 ANN 索引的表模型要求。
|
||||
// WeKnora 在 Go 端用 delete + insert 保持按 id 替换的写入语义。
|
||||
// Academy 在 Go 端用 delete + insert 保持按 id 替换的写入语义。
|
||||
// - INVERTED 索引覆盖所有过滤字段 + 中文分词的 content 全文索引。
|
||||
// - ANN 索引使用 HNSW + inner_product;Doris 写入/查询前会对向量单位化,
|
||||
// 因此整体仍保持与其他向量库一致的 cosine 相似度语义。
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/logger"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
// Stream Load 相关常量。
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// VectorEmbedding defines the Elasticsearch document structure for vector embeddings
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
typesLocal "github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
typesLocal "academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/elastic/go-elasticsearch/v7"
|
||||
)
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
elasticsearchRetriever "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch"
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
typesLocal "github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
elasticsearchRetriever "academy/internal/application/repository/retriever/elasticsearch"
|
||||
"academy/internal/config"
|
||||
"academy/internal/logger"
|
||||
typesLocal "academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/elastic/go-elasticsearch/v7"
|
||||
"github.com/elastic/go-elasticsearch/v7/esapi"
|
||||
"github.com/google/uuid"
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
typesLocal "github.com/Tencent/WeKnora/internal/types"
|
||||
typesLocal "academy/internal/types"
|
||||
)
|
||||
|
||||
// Regression test for #3156: the script_score source must floor the cosine
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
typesLocal "github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
typesLocal "academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/elastic/go-elasticsearch/v8"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
elasticsearchRetriever "github.com/Tencent/WeKnora/internal/application/repository/retriever/elasticsearch"
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
typesLocal "github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
elasticsearchRetriever "academy/internal/application/repository/retriever/elasticsearch"
|
||||
"academy/internal/config"
|
||||
"academy/internal/logger"
|
||||
typesLocal "academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/elastic/go-elasticsearch/v8"
|
||||
"github.com/elastic/go-elasticsearch/v8/typedapi/core/bulk"
|
||||
"github.com/elastic/go-elasticsearch/v8/typedapi/core/search"
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
typesLocal "github.com/Tencent/WeKnora/internal/types"
|
||||
typesLocal "academy/internal/types"
|
||||
)
|
||||
|
||||
// Regression test for #3156: the script_score source must floor the cosine
|
||||
|
||||
@@ -333,7 +333,7 @@ func newCopyMilvusHarness(t *testing.T, rows []copyTestRow) *copyMilvusHarness {
|
||||
return ©MilvusHarness{
|
||||
repo: &milvusRepository{
|
||||
client: c,
|
||||
collectionBaseName: "weknora_embeddings",
|
||||
collectionBaseName: "academy_embeddings",
|
||||
metricType: entity.IP,
|
||||
},
|
||||
fake: fake,
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
||||
@@ -87,7 +87,7 @@ func newKeywordsMilvusHarness(t *testing.T, collections []string,
|
||||
t.Cleanup(func() { _ = c.Close(context.Background()) })
|
||||
|
||||
return &keywordsMilvusHarness{
|
||||
repo: &milvusRepository{client: c, collectionBaseName: "weknora_embeddings"},
|
||||
repo: &milvusRepository{client: c, collectionBaseName: "academy_embeddings"},
|
||||
fake: fake,
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func captureMilvusLogs(t *testing.T) *bytes.Buffer {
|
||||
func TestMilvusKeywordsRetrieveFailsWhenEveryMatchedCollectionFails(t *testing.T) {
|
||||
logs := captureMilvusLogs(t)
|
||||
harness := newKeywordsMilvusHarness(t,
|
||||
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536", "other_collection"},
|
||||
[]string{"academy_embeddings_1024", "academy_embeddings_1536", "other_collection"},
|
||||
func(string) (*milvuspb.SearchResults, error) { return failedMilvusSearch(), nil },
|
||||
)
|
||||
|
||||
@@ -176,7 +176,7 @@ func TestMilvusKeywordsRetrieveFailsWhenEveryMatchedCollectionFails(t *testing.T
|
||||
require.Contains(t, err.Error(), "milvus keyword search unavailable")
|
||||
require.Nil(t, results, "no result set may accompany the error")
|
||||
require.Equal(t,
|
||||
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536"}, harness.fake.searches,
|
||||
[]string{"academy_embeddings_1024", "academy_embeddings_1536"}, harness.fake.searches,
|
||||
"only base-name collections are searched",
|
||||
)
|
||||
require.NotContains(t, logs.String(), "No keyword matches found",
|
||||
@@ -190,9 +190,9 @@ func TestMilvusKeywordsRetrieveFailsWhenEveryMatchedCollectionFails(t *testing.T
|
||||
func TestMilvusKeywordsRetrieveKeepsResultsWhenOnlySomeCollectionsFail(t *testing.T) {
|
||||
logs := captureMilvusLogs(t)
|
||||
harness := newKeywordsMilvusHarness(t,
|
||||
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536"},
|
||||
[]string{"academy_embeddings_1024", "academy_embeddings_1536"},
|
||||
func(name string) (*milvuspb.SearchResults, error) {
|
||||
if name == "weknora_embeddings_1024" {
|
||||
if name == "academy_embeddings_1024" {
|
||||
return failedMilvusSearch(), nil
|
||||
}
|
||||
return milvusSearchHits("chunk-1", "invoice total 42"), nil
|
||||
@@ -221,7 +221,7 @@ func TestMilvusKeywordsRetrieveKeepsResultsWhenOnlySomeCollectionsFail(t *testin
|
||||
// conclusion log still fires.
|
||||
func TestMilvusKeywordsRetrieveReportsNoMatchesWhenNothingFailed(t *testing.T) {
|
||||
logs := captureMilvusLogs(t)
|
||||
harness := newKeywordsMilvusHarness(t, []string{"weknora_embeddings_1024"},
|
||||
harness := newKeywordsMilvusHarness(t, []string{"academy_embeddings_1024"},
|
||||
func(string) (*milvuspb.SearchResults, error) { return emptyMilvusSearch(), nil },
|
||||
)
|
||||
|
||||
@@ -240,9 +240,9 @@ func TestMilvusKeywordsRetrieveReportsNoMatchesWhenNothingFailed(t *testing.T) {
|
||||
func TestMilvusKeywordsRetrieveMarksPartialFailureWhenNothingHit(t *testing.T) {
|
||||
logs := captureMilvusLogs(t)
|
||||
harness := newKeywordsMilvusHarness(t,
|
||||
[]string{"weknora_embeddings_1024", "weknora_embeddings_1536"},
|
||||
[]string{"academy_embeddings_1024", "academy_embeddings_1536"},
|
||||
func(name string) (*milvuspb.SearchResults, error) {
|
||||
if name == "weknora_embeddings_1024" {
|
||||
if name == "academy_embeddings_1024" {
|
||||
return failedMilvusSearch(), nil
|
||||
}
|
||||
return emptyMilvusSearch(), nil
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/milvus-io/milvus/client/v2/index"
|
||||
client "github.com/milvus-io/milvus/client/v2/milvusclient"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
const defaultMultilingualMigrationBatchSize = 64
|
||||
@@ -56,7 +56,7 @@ type MigrationSummary struct {
|
||||
MigratedRows int
|
||||
}
|
||||
|
||||
// MigrateLegacyCollections copies all legacy WeKnora Milvus collections to a
|
||||
// MigrateLegacyCollections copies all legacy Academy Milvus collections to a
|
||||
// new multilingual collection base. Existing dense vectors are reused; only
|
||||
// Milvus's BM25 sparse vectors are regenerated from content and language.
|
||||
//
|
||||
|
||||
@@ -11,22 +11,22 @@ import (
|
||||
)
|
||||
|
||||
func TestCollectionDimensionForBase(t *testing.T) {
|
||||
dimension, ok := collectionDimensionForBase("weknora_embeddings_1536", "weknora_embeddings")
|
||||
dimension, ok := collectionDimensionForBase("academy_embeddings_1536", "academy_embeddings")
|
||||
require.True(t, ok)
|
||||
require.Equal(t, 1536, dimension)
|
||||
|
||||
_, ok = collectionDimensionForBase("weknora_embeddings_multilingual_1536", "weknora_embeddings")
|
||||
_, ok = collectionDimensionForBase("academy_embeddings_multilingual_1536", "academy_embeddings")
|
||||
require.False(t, ok)
|
||||
_, ok = collectionDimensionForBase("weknora_embeddings", "weknora_embeddings")
|
||||
_, ok = collectionDimensionForBase("academy_embeddings", "academy_embeddings")
|
||||
require.False(t, ok)
|
||||
_, ok = collectionDimensionForBase("weknora_embeddings_1536_backup", "weknora_embeddings")
|
||||
_, ok = collectionDimensionForBase("academy_embeddings_1536_backup", "academy_embeddings")
|
||||
require.False(t, ok)
|
||||
|
||||
require.True(t, matchesDimensionCollection(
|
||||
"weknora_embeddings_multilingual_1536",
|
||||
"weknora_embeddings_multilingual",
|
||||
"academy_embeddings_multilingual_1536",
|
||||
"academy_embeddings_multilingual",
|
||||
))
|
||||
require.False(t, matchesDimensionCollection("weknora_embeddings_1536", "weknora_embeddings_multilingual"))
|
||||
require.False(t, matchesDimensionCollection("academy_embeddings_1536", "academy_embeddings_multilingual"))
|
||||
}
|
||||
|
||||
func TestParseMetricType(t *testing.T) {
|
||||
|
||||
@@ -15,15 +15,15 @@ import (
|
||||
"github.com/milvus-io/milvus/client/v2/index"
|
||||
client "github.com/milvus-io/milvus/client/v2/milvusclient"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
)
|
||||
|
||||
const (
|
||||
envMilvusCollection = "MILVUS_COLLECTION"
|
||||
envMilvusMetricType = "MILVUS_METRIC_TYPE"
|
||||
defaultCollectionName = "weknora_embeddings"
|
||||
defaultCollectionName = "academy_embeddings"
|
||||
fieldSourceID = "source_id"
|
||||
fieldSourceType = "source_type"
|
||||
fieldChunkID = "chunk_id"
|
||||
@@ -83,7 +83,7 @@ func (m *milvusRepository) getCollectionName(dimension int) string {
|
||||
}
|
||||
|
||||
// collectionAnalyzerMode inspects a collection once and caches whether it
|
||||
// uses the multilingual schema. Older WeKnora collections do not have the
|
||||
// uses the multilingual schema. Older Academy collections do not have the
|
||||
// language field, so they must continue using the legacy upsert and search
|
||||
// paths until they are migrated.
|
||||
func (m *milvusRepository) collectionAnalyzerMode(
|
||||
@@ -142,7 +142,7 @@ func (m *milvusRepository) ensureCollection(ctx context.Context, dimension int)
|
||||
// Define schema
|
||||
schema := &entity.Schema{
|
||||
CollectionName: collectionName,
|
||||
Description: fmt.Sprintf("WeKnora embeddings collection with dimension %d", dimension),
|
||||
Description: fmt.Sprintf("Academy embeddings collection with dimension %d", dimension),
|
||||
AutoID: false,
|
||||
Fields: []*entity.Field{
|
||||
entity.NewField().
|
||||
@@ -230,7 +230,7 @@ func (m *milvusRepository) ensureCollection(ctx context.Context, dimension int)
|
||||
log.Infof("[Milvus] Successfully created collection %s", collectionName)
|
||||
m.collectionAnalyzerModes.Store(collectionName, collectionAnalyzerMulti)
|
||||
} else {
|
||||
// Existing collections may have been created by an older WeKnora
|
||||
// Existing collections may have been created by an older Academy
|
||||
// version. Keep them readable and writable until they are migrated.
|
||||
if _, err := m.collectionAnalyzerMode(ctx, collectionName); err != nil {
|
||||
return err
|
||||
@@ -1407,7 +1407,7 @@ func convertResultSet(resultSet []client.ResultSet) ([]*MilvusVectorEmbeddingWit
|
||||
|
||||
// metricToSimilarity converts a raw vector-search score into cosine
|
||||
// similarity, the scale callers rank and threshold on. IP and COSINE already
|
||||
// are for the L2-normalized embeddings WeKnora indexes. Milvus L2 returns
|
||||
// are for the L2-normalized embeddings Academy indexes. Milvus L2 returns
|
||||
// the squared Euclidean distance (smaller is better), which for unit vectors
|
||||
// is 2 - 2cos; passing it through ranked the farthest hits first.
|
||||
func (m *milvusRepository) metricToSimilarity(score float64) float64 {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -45,13 +45,13 @@ func TestUpdateChunkEnabledStatusInCollectionSkipsEmptyChunkIDs(t *testing.T) {
|
||||
|
||||
require.NoError(t, repo.updateChunkEnabledStatusInCollection(
|
||||
context.Background(),
|
||||
"weknora_embeddings_1024",
|
||||
"academy_embeddings_1024",
|
||||
nil,
|
||||
false,
|
||||
))
|
||||
require.NoError(t, repo.updateChunkEnabledStatusInCollection(
|
||||
context.Background(),
|
||||
"weknora_embeddings_1024",
|
||||
"academy_embeddings_1024",
|
||||
[]string{},
|
||||
true,
|
||||
))
|
||||
@@ -61,12 +61,12 @@ func TestUpdateChunkEnabledStatusInCollectionsPropagatesFailure(t *testing.T) {
|
||||
wantErr := errors.New("upsert failed")
|
||||
err := updateChunkEnabledStatusInCollections(
|
||||
context.Background(),
|
||||
[]string{"other_collection", "weknora_embeddings_1024"},
|
||||
"weknora_embeddings",
|
||||
[]string{"other_collection", "academy_embeddings_1024"},
|
||||
"academy_embeddings",
|
||||
nil,
|
||||
[]string{"chunk-1"},
|
||||
func(_ context.Context, collection string, _ []string, enabled bool) error {
|
||||
if collection == "weknora_embeddings_1024" && !enabled {
|
||||
if collection == "academy_embeddings_1024" && !enabled {
|
||||
return wantErr
|
||||
}
|
||||
return nil
|
||||
@@ -82,11 +82,11 @@ func TestUpdateChunkEnabledStatusInCollectionsIgnoresExtendedPrefix(t *testing.T
|
||||
context.Background(),
|
||||
[]string{
|
||||
"other_collection",
|
||||
"weknora_embeddings_1024",
|
||||
"weknora_embeddings_multilingual_1024",
|
||||
"weknora_embeddings_1024_backup",
|
||||
"academy_embeddings_1024",
|
||||
"academy_embeddings_multilingual_1024",
|
||||
"academy_embeddings_1024_backup",
|
||||
},
|
||||
"weknora_embeddings",
|
||||
"academy_embeddings",
|
||||
[]string{"chunk-1"},
|
||||
nil,
|
||||
func(_ context.Context, collection string, _ []string, _ bool) error {
|
||||
@@ -98,5 +98,5 @@ func TestUpdateChunkEnabledStatusInCollectionsIgnoresExtendedPrefix(t *testing.T
|
||||
},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"weknora_embeddings_1024"}, seen)
|
||||
require.Equal(t, []string{"academy_embeddings_1024"}, seen)
|
||||
}
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -51,9 +51,9 @@ func TestGraphSearchProjectionValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGraphSearchIntegration(t *testing.T) {
|
||||
uri := os.Getenv("WEKNORA_NEO4J_TEST_URI")
|
||||
uri := os.Getenv("ACADEMY_NEO4J_TEST_URI")
|
||||
if uri == "" {
|
||||
t.Skip("set WEKNORA_NEO4J_TEST_URI to run the live public graph-query regression")
|
||||
t.Skip("set ACADEMY_NEO4J_TEST_URI to run the live public graph-query regression")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,19 +7,19 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/neo4j/neo4j-go-driver/v6/neo4j"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Run against a disposable Neo4j instance with authentication disabled:
|
||||
// Set WEKNORA_NEO4J_TEST_URI=bolt://127.0.0.1:7687, then run:
|
||||
// Set ACADEMY_NEO4J_TEST_URI=bolt://127.0.0.1:7687, then run:
|
||||
// go test ./internal/application/repository/retriever/neo4j -run Integration
|
||||
func TestSearchNodeIntegration(t *testing.T) {
|
||||
uri := os.Getenv("WEKNORA_NEO4J_TEST_URI")
|
||||
uri := os.Getenv("ACADEMY_NEO4J_TEST_URI")
|
||||
if uri == "" {
|
||||
t.Skip("set WEKNORA_NEO4J_TEST_URI to run the live Neo4j regression")
|
||||
t.Skip("set ACADEMY_NEO4J_TEST_URI to run the live Neo4j regression")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// spySink records audit events for assertions.
|
||||
@@ -127,7 +127,7 @@ func TestAuditSink_NopByDefault(t *testing.T) {
|
||||
var _ AuditSink = nopSink{} // compile-time assertion
|
||||
r := &Repository{} // sink left nil
|
||||
// Must not panic.
|
||||
r.auditSink().EmitIndexCreated(context.Background(), "weknora_768", 768)
|
||||
r.auditSink().EmitIndexCreated(context.Background(), "academy_768", 768)
|
||||
r.auditSink().EmitReindexExecuted(context.Background(), "a", "b", 3)
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func TestAuditSink_EmitIndexCreated_OnEnsureReady(t *testing.T) {
|
||||
t.Fatalf("want 1 index_created event, got %d", len(spy.indexCreated))
|
||||
}
|
||||
got := spy.indexCreated[0]
|
||||
if got.alias != "weknora_test_768" || got.dim != 768 {
|
||||
if got.alias != "academy_test_768" || got.dim != 768 {
|
||||
t.Errorf("event mismatch: %+v", got)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
// inspectByQueryResponse parses an _update_by_query / _delete_by_query
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package opensearch
|
||||
|
||||
import "github.com/Tencent/WeKnora/internal/types"
|
||||
import "academy/internal/types"
|
||||
|
||||
// internalCfg is the driver-internal, immutable view of IndexConfig.
|
||||
// Defaults are chosen so the env-path (no IndexConfig) and DB-store path
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/google/uuid"
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// copyBatchSize is the pagination size for the source scan. Kept under the
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// additionalParams contract (verified against
|
||||
|
||||
@@ -3,7 +3,7 @@ package opensearch
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// TestConnection verifies an OpenSearch cluster is reachable, runs a
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// clusterHandler serves both GET / (version info) and /_cat/plugins, so the
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
)
|
||||
|
||||
// createIndexAndAlias creates "<alias>_v1" with the full k-NN mapping
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// retrieveFilters is the typed shape of OpenSearch query filter
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/opensearch-project/opensearch-go/v4"
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
)
|
||||
|
||||
// EngineAwareNormalizer applies the documented per-engine cosine-score
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
// caller reads zero before the first caller persists.
|
||||
type Repository struct {
|
||||
client *osapi.Client
|
||||
baseIndex string // pre-suffix base name, e.g. "weknora_abcdef012345"
|
||||
baseIndex string // pre-suffix base name, e.g. "academy_abcdef012345"
|
||||
cfg internalCfg // immutable after construction (value, not pointer)
|
||||
|
||||
// Per-dimension lazy initialization. ensureReady(ctx, dim) inserts an
|
||||
@@ -84,13 +84,13 @@ var _ interfaces.RetrieveEngineRepository = (*Repository)(nil)
|
||||
// storeID is the VectorStore.ID owning this repository instance. It is
|
||||
// folded into the base index name so multiple OpenSearch VectorStores
|
||||
// pointing at the same cluster do not collide:
|
||||
// - storeID == "" — env-path; no prefix, base index = "weknora".
|
||||
// - storeID == "" — env-path; no prefix, base index = "academy".
|
||||
// - len(storeID) >= 16 — DB-store path; prefix = storeID[:12]
|
||||
// (48-bit collision space).
|
||||
// - 1..15 chars — rejected with ErrConfigInvalid.
|
||||
//
|
||||
// indexCfg is optional — pass nil to use env var (OPENSEARCH_INDEX) or
|
||||
// default ("weknora") values.
|
||||
// default ("academy") values.
|
||||
//
|
||||
// Optional behavior is configured via functional options (e.g.
|
||||
// WithAuditSink). Passing no options keeps audit emission as a no-op, so the
|
||||
@@ -114,7 +114,7 @@ func NewRepository(
|
||||
)
|
||||
}
|
||||
|
||||
base := types.ResolveIndexName(indexCfg, "OPENSEARCH_INDEX", "weknora")
|
||||
base := types.ResolveIndexName(indexCfg, "OPENSEARCH_INDEX", "academy")
|
||||
if storeID != "" {
|
||||
// 12 hex chars → 48-bit collision space (UUID is 32 chars; using
|
||||
// half gives strong-enough collision avoidance for the realistic
|
||||
|
||||
@@ -18,8 +18,8 @@ import (
|
||||
"github.com/opensearch-project/opensearch-go/v4"
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
)
|
||||
|
||||
// ============================================================================
|
||||
@@ -83,7 +83,7 @@ func newTestRepo(t *testing.T, handler http.HandlerFunc) (*Repository, *httptest
|
||||
client := newTestClient(t, ts.URL)
|
||||
repo := &Repository{
|
||||
client: client,
|
||||
baseIndex: "weknora_test",
|
||||
baseIndex: "academy_test",
|
||||
cfg: internalCfg{
|
||||
shards: 1, replicas: 0,
|
||||
knnEngine: "lucene",
|
||||
@@ -192,8 +192,8 @@ func TestIsTransientErr(t *testing.T) {
|
||||
func TestSanitizeIndexName_AcceptsValidNames(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []string{
|
||||
"weknora",
|
||||
"weknora_abc123def456_768",
|
||||
"academy",
|
||||
"academy_abc123def456_768",
|
||||
"a",
|
||||
"1abc",
|
||||
"foo-bar_baz",
|
||||
@@ -977,7 +977,7 @@ func TestEnsureReady_ConcurrentCallers_SingleCreate(t *testing.T) {
|
||||
|
||||
repo := &Repository{
|
||||
client: newTestClient(t, ts.URL),
|
||||
baseIndex: "weknora_test",
|
||||
baseIndex: "academy_test",
|
||||
cfg: internalCfg{shards: 1, replicas: 0, knnEngine: "lucene", hnswM: 16, hnswEFConstruction: 100, efSearch: 100},
|
||||
once: make(map[int]*sync.Once),
|
||||
initErr: make(map[int]error),
|
||||
@@ -1006,7 +1006,7 @@ func TestEnsureReady_PerDimensionIsolation(t *testing.T) {
|
||||
|
||||
repo := &Repository{
|
||||
client: newTestClient(t, ts.URL),
|
||||
baseIndex: "weknora_test",
|
||||
baseIndex: "academy_test",
|
||||
cfg: internalCfg{shards: 1, replicas: 0, knnEngine: "lucene", hnswM: 16, hnswEFConstruction: 100, efSearch: 100},
|
||||
once: make(map[int]*sync.Once),
|
||||
initErr: make(map[int]error),
|
||||
@@ -1058,7 +1058,7 @@ func TestEnsureReady_TransientError_NotCached(t *testing.T) {
|
||||
|
||||
repo := &Repository{
|
||||
client: newTestClient(t, ts.URL),
|
||||
baseIndex: "weknora_test",
|
||||
baseIndex: "academy_test",
|
||||
cfg: internalCfg{shards: 1, replicas: 0, knnEngine: "lucene", hnswM: 16, hnswEFConstruction: 100, efSearch: 100},
|
||||
once: make(map[int]*sync.Once),
|
||||
initErr: make(map[int]error),
|
||||
@@ -1083,17 +1083,17 @@ func TestEnsureReady_TransientError_NotCached(t *testing.T) {
|
||||
|
||||
func TestIndexAlias(t *testing.T) {
|
||||
t.Parallel()
|
||||
r := &Repository{baseIndex: "weknora_abc123def456"}
|
||||
if got := r.indexAlias(768); got != "weknora_abc123def456_768" {
|
||||
t.Errorf("indexAlias(768): want weknora_abc123def456_768, got %s", got)
|
||||
r := &Repository{baseIndex: "academy_abc123def456"}
|
||||
if got := r.indexAlias(768); got != "academy_abc123def456_768" {
|
||||
t.Errorf("indexAlias(768): want academy_abc123def456_768, got %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeywordsIndex(t *testing.T) {
|
||||
t.Parallel()
|
||||
r := &Repository{baseIndex: "weknora_abc123def456"}
|
||||
if got := r.keywordsIndex(); got != "weknora_abc123def456_keywords" {
|
||||
t.Errorf("keywordsIndex: want weknora_abc123def456_keywords, got %s", got)
|
||||
r := &Repository{baseIndex: "academy_abc123def456"}
|
||||
if got := r.keywordsIndex(); got != "academy_abc123def456_keywords" {
|
||||
t.Errorf("keywordsIndex: want academy_abc123def456_keywords, got %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// Retrieve dispatches to vectorRetrieve or keywordsRetrieve based on
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// The k-NN plugin reports (1 + cos) / 2; vector hits leave the driver as
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package opensearch
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// This file holds the remaining stubs for methods whose real implementation
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/opensearch-project/opensearch-go/v4"
|
||||
osapi "github.com/opensearch-project/opensearch-go/v4/opensearchapi"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
"academy/internal/types"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
// NewOpenSearchClient builds a TLS-hardened, pool-tuned *osapi.Client for
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// TestNewOpenSearchClient_RejectsEmptyAddr verifies the constructor
|
||||
|
||||
+3
-3
@@ -13,13 +13,13 @@ import (
|
||||
|
||||
// TestKeywordScoreCatalogCompatibility checks the actual PostgreSQL catalog
|
||||
// query, including preference and signatures, rather than mocking its result.
|
||||
// Set WEKNORA_RETRIEVER_TEST_POSTGRES_DSN to a disposable PostgreSQL database
|
||||
// Set ACADEMY_RETRIEVER_TEST_POSTGRES_DSN to a disposable PostgreSQL database
|
||||
// without pg_search installed. Fixtures are rolled back after each subtest;
|
||||
// existing scoring schemas are never replaced or dropped.
|
||||
func TestKeywordScoreCatalogCompatibility(t *testing.T) {
|
||||
dsn := os.Getenv("WEKNORA_RETRIEVER_TEST_POSTGRES_DSN")
|
||||
dsn := os.Getenv("ACADEMY_RETRIEVER_TEST_POSTGRES_DSN")
|
||||
if dsn == "" {
|
||||
t.Skip("set WEKNORA_RETRIEVER_TEST_POSTGRES_DSN to run PostgreSQL catalog tests")
|
||||
t.Skip("set ACADEMY_RETRIEVER_TEST_POSTGRES_DSN to run PostgreSQL catalog tests")
|
||||
}
|
||||
db, err := gorm.Open(gormpostgres.Open(dsn), &gorm.Config{
|
||||
Logger: logger.Default.LogMode(logger.Silent),
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
gormpostgres "gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/common"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/common"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pgvector/pgvector-go"
|
||||
"gorm.io/gorm"
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/common"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/common"
|
||||
"academy/internal/types"
|
||||
"github.com/pgvector/pgvector-go"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/common"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/common"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/google/uuid"
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
const (
|
||||
envQdrantCollection = "QDRANT_COLLECTION"
|
||||
defaultCollectionName = "weknora_embeddings"
|
||||
defaultCollectionName = "academy_embeddings"
|
||||
fieldContent = "content"
|
||||
fieldSourceID = "source_id"
|
||||
fieldSourceType = "source_type"
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"academy/internal/logger"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/common"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/common"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
sqlite_vec "github.com/asg017/sqlite-vec-go-bindings/cgo"
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
sqlite_vec "github.com/asg017/sqlite-vec-go-bindings/cgo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/tencent/vectordatabase-sdk-go/tcvdbtext/encoder"
|
||||
"github.com/tencent/vectordatabase-sdk-go/tcvectordb"
|
||||
)
|
||||
@@ -431,7 +431,7 @@ func (r *repository) ensureCollection(ctx context.Context, dimension int) error
|
||||
collectionName,
|
||||
uint32(r.shardsNum),
|
||||
uint32(r.replicasNum),
|
||||
fmt.Sprintf("WeKnora embeddings collection with dimension %d", dimension),
|
||||
fmt.Sprintf("Academy embeddings collection with dimension %d", dimension),
|
||||
indexes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tencent/vectordatabase-sdk-go/tcvdbtext/encoder"
|
||||
)
|
||||
@@ -102,9 +102,9 @@ func TestTencentVectorDBUsesConfiguredReplicaNumber(t *testing.T) {
|
||||
func TestCollectionNameUsesDimensionSuffixByDefault(t *testing.T) {
|
||||
repo := NewTencentVectorDBRetrieveEngineRepository(nil, "", nil).(*repository)
|
||||
|
||||
assert.Equal(t, "weknora_embeddings_1024", repo.collectionName(1024))
|
||||
assert.True(t, repo.matchesCollection("weknora_embeddings_1024"))
|
||||
assert.False(t, repo.matchesCollection("weknora_embeddings"))
|
||||
assert.Equal(t, "academy_embeddings_1024", repo.collectionName(1024))
|
||||
assert.True(t, repo.matchesCollection("academy_embeddings_1024"))
|
||||
assert.False(t, repo.matchesCollection("academy_embeddings"))
|
||||
}
|
||||
|
||||
func TestCollectionNameRespectsExplicitCollectionName(t *testing.T) {
|
||||
|
||||
@@ -11,8 +11,8 @@ const (
|
||||
envTencentVectorDBDatabase = "TENCENT_VECTORDB_DATABASE"
|
||||
envTencentVectorDBCollection = "TENCENT_VECTORDB_COLLECTION"
|
||||
envTencentVectorDBReplicaNum = "TENCENT_VECTORDB_REPLICA_NUMBER"
|
||||
defaultDatabaseName = "weknora"
|
||||
defaultCollectionName = "weknora_embeddings"
|
||||
defaultDatabaseName = "academy"
|
||||
defaultCollectionName = "academy_embeddings"
|
||||
defaultReplicaNumber = 1
|
||||
|
||||
fieldID = "id"
|
||||
|
||||
@@ -442,7 +442,7 @@ func TestCopyIndicesLowersTheQueryLimitWhenTheServerRefuses(t *testing.T) {
|
||||
// more objects" turns a failed query into a successful, silently truncated copy
|
||||
// - and the response type check used to panic before it could even get there.
|
||||
func TestCopyIndicesReportsAQueryError(t *testing.T) {
|
||||
const failure = "class Weknora_embeddings_64 does not exist"
|
||||
const failure = "class Academy_embeddings_64 does not exist"
|
||||
source := copyTestSingleVectorChunks("chunk-0")
|
||||
source.queryError = failure
|
||||
repo := source.serve(t)
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/google/uuid"
|
||||
"github.com/weaviate/weaviate-go-client/v5/weaviate"
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
const (
|
||||
envWeaviateCollection = "WEAVIATE_COLLECTION"
|
||||
defaultCollectionName = "Weknora_embeddings"
|
||||
defaultCollectionName = "Academy_embeddings"
|
||||
fieldContent = "content"
|
||||
fieldSourceID = "source_id"
|
||||
fieldSourceType = "source_type"
|
||||
@@ -95,7 +95,7 @@ func (w *weaviateRepository) ensureCollection(ctx context.Context, dimension int
|
||||
//定义class结构
|
||||
classObj := models.Class{
|
||||
Class: collectionName,
|
||||
Description: fmt.Sprintf("WeKnora embeddings collection with dimension %d", dimension),
|
||||
Description: fmt.Sprintf("Academy embeddings collection with dimension %d", dimension),
|
||||
VectorConfig: map[string]models.VectorConfig{
|
||||
fieldEmbedding: {
|
||||
VectorIndexType: "hnsw",
|
||||
|
||||
@@ -55,7 +55,7 @@ func (s *schemaTestServer) repository(t *testing.T) *weaviateRepository {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"class":"Weknora_embeddings_1024"}`))
|
||||
_, _ = w.Write([]byte(`{"class":"Academy_embeddings_1024"}`))
|
||||
case r.Method == http.MethodPost && r.URL.Path == "/v1/schema":
|
||||
s.mu.Lock()
|
||||
s.creates++
|
||||
@@ -76,7 +76,7 @@ func (s *schemaTestServer) repository(t *testing.T) *weaviateRepository {
|
||||
t.Cleanup(server.Close)
|
||||
client, err := sdk.NewClient(sdk.Config{Scheme: "http", Host: strings.TrimPrefix(server.URL, "http://")})
|
||||
require.NoError(t, err)
|
||||
return &weaviateRepository{client: client, collectionBaseName: "Weknora_embeddings"}
|
||||
return &weaviateRepository{client: client, collectionBaseName: "Academy_embeddings"}
|
||||
}
|
||||
|
||||
// The first batches written at a new dimension are saved by several workers at
|
||||
@@ -107,13 +107,13 @@ func TestEnsureCollectionToleratesConcurrentCreation(t *testing.T) {
|
||||
create: func(attempt int) (int, string) {
|
||||
switch {
|
||||
case attempt == 1:
|
||||
return http.StatusOK, `{"class":"Weknora_embeddings_1024"}`
|
||||
return http.StatusOK, `{"class":"Academy_embeddings_1024"}`
|
||||
case attempt%2 == 0:
|
||||
return http.StatusUnprocessableEntity,
|
||||
weaviateErrorBody("updating schema: TYPE_ADD_CLASS: class already exists")
|
||||
default:
|
||||
return http.StatusUnprocessableEntity,
|
||||
weaviateErrorBody("class name Weknora_embeddings_1024 already exists")
|
||||
weaviateErrorBody("class name Academy_embeddings_1024 already exists")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package weaviate
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// Weaviate certainty is (1 + cos) / 2; vector hits leave the driver as
|
||||
|
||||
Reference in new issue
Block a user