feat: 将 Manticore 相关检查更新为使用 "search" 应用

This commit is contained in:
kuaifan 2026-01-05 05:51:48 +00:00
parent 5cc3d60e15
commit 8ab810c670
17 changed files with 70 additions and 70 deletions

View File

@ -83,7 +83,7 @@ class GenerateManticoreVectors extends Command
public function handle(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
$this->error("应用「Manticore Search」未安装");
return 1;
}

View File

@ -30,7 +30,7 @@ class SyncFileToManticore extends Command
public function handle(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
$this->error("应用「Manticore Search」未安装");
return 1;
}

View File

@ -31,7 +31,7 @@ class SyncMsgToManticore extends Command
public function handle(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
$this->error("应用「Manticore Search」未安装");
return 1;
}

View File

@ -30,7 +30,7 @@ class SyncProjectToManticore extends Command
public function handle(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
$this->error("应用「Manticore Search」未安装");
return 1;
}

View File

@ -30,7 +30,7 @@ class SyncTaskToManticore extends Command
public function handle(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
$this->error("应用「Manticore Search」未安装");
return 1;
}

View File

@ -30,7 +30,7 @@ class SyncUserToManticore extends Command
public function handle(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
$this->error("应用「Manticore Search」未安装");
return 1;
}

View File

@ -54,7 +54,7 @@ class SearchController extends AbstractController
}
// 优先使用 Manticore 搜索
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
$results = ManticoreUser::search($key, $searchType, $take);
// 补充用户完整信息
@ -147,7 +147,7 @@ class SearchController extends AbstractController
}
// 优先使用 Manticore 搜索
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
$results = ManticoreProject::search($user->userid, $key, $searchType, $take);
// 补充项目完整信息
@ -229,7 +229,7 @@ class SearchController extends AbstractController
}
// 优先使用 Manticore 搜索
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
$results = ManticoreTask::search($user->userid, $key, $searchType, $take);
// 补充任务完整信息
@ -320,7 +320,7 @@ class SearchController extends AbstractController
}
// 优先使用 Manticore 搜索
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
$results = ManticoreFile::search($user->userid, $key, $searchType, 0, $take);
// 补充文件完整信息
@ -444,7 +444,7 @@ class SearchController extends AbstractController
}
// 优先使用 Manticore 搜索
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
$results = ManticoreMsg::search($user->userid, $key, $searchType, 0, $take, $dialogId);
} else {
// MySQL 回退搜索

View File

@ -28,8 +28,8 @@ class ManticoreBase
*/
public function __construct()
{
$this->host = env('MANTICORE_HOST', 'manticore');
$this->port = (int) env('MANTICORE_PORT', 9306);
$this->host = env('SEARCH_HOST', 'search');
$this->port = (int) env('SEARCH_PORT', 9306);
}
/**
@ -37,7 +37,7 @@ class ManticoreBase
*/
private function getConnection(): ?PDO
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return null;
}
@ -178,7 +178,7 @@ class ManticoreBase
*/
public static function isInstalled(): bool
{
return Apps::isInstalled("manticore");
return Apps::isInstalled("search");
}
/**

View File

@ -86,7 +86,7 @@ class ManticoreFile
return [];
}
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
// 未安装 Manticore降级到 MySQL LIKE 搜索
return self::searchByMysql($userid, $keyword, $from, $size);
}
@ -223,7 +223,7 @@ class ManticoreFile
*/
public static function sync(File $file, bool $withVector = false): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -327,7 +327,7 @@ class ManticoreFile
*/
public static function batchSync(iterable $files, bool $withVector = false): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -348,7 +348,7 @@ class ManticoreFile
*/
public static function delete(int $fileId): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -432,7 +432,7 @@ class ManticoreFile
*/
public static function clear(): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -446,7 +446,7 @@ class ManticoreFile
*/
public static function getIndexedCount(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -466,7 +466,7 @@ class ManticoreFile
*/
public static function updateAllowedUsers(int $fileId): bool
{
if (!Apps::isInstalled("manticore") || $fileId <= 0) {
if (!Apps::isInstalled("search") || $fileId <= 0) {
return false;
}
@ -498,7 +498,7 @@ class ManticoreFile
*/
public static function generateVectorsBatch(array $fileIds, int $batchSize = 20): int
{
if (!Apps::isInstalled("manticore") || !Apps::isInstalled("ai") || empty($fileIds)) {
if (!Apps::isInstalled("search") || !Apps::isInstalled("ai") || empty($fileIds)) {
return 0;
}

View File

@ -21,7 +21,7 @@ class ManticoreKeyValue
*/
public static function get(string $key, $default = null)
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return $default;
}
@ -43,7 +43,7 @@ class ManticoreKeyValue
*/
public static function set(string $key, $value): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -70,7 +70,7 @@ class ManticoreKeyValue
*/
public static function delete(string $key): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -85,7 +85,7 @@ class ManticoreKeyValue
*/
public static function clear(): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -101,7 +101,7 @@ class ManticoreKeyValue
*/
public static function exists(string $key): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -121,7 +121,7 @@ class ManticoreKeyValue
*/
public static function all(): array
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return [];
}

View File

@ -86,7 +86,7 @@ class ManticoreMsg
return [];
}
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return [];
}
@ -169,7 +169,7 @@ class ManticoreMsg
}
// 未安装 Manticore 时使用 MySQL 回退搜索
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return self::searchDialogsByMysql($userid, $keyword, $from, $size);
}
@ -336,7 +336,7 @@ class ManticoreMsg
*/
public static function sync(WebSocketDialogMsg $msg, bool $withVector = false): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -396,7 +396,7 @@ class ManticoreMsg
*/
public static function batchSync(iterable $msgs, bool $withVector = false): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -418,7 +418,7 @@ class ManticoreMsg
*/
public static function generateVectorsBatch(array $msgIds, int $batchSize = 20): int
{
if (!Apps::isInstalled("manticore") || !Apps::isInstalled('ai') || empty($msgIds)) {
if (!Apps::isInstalled("search") || !Apps::isInstalled('ai') || empty($msgIds)) {
return 0;
}
@ -506,7 +506,7 @@ class ManticoreMsg
*/
public static function delete(int $msgId): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -520,7 +520,7 @@ class ManticoreMsg
*/
public static function clear(): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -534,7 +534,7 @@ class ManticoreMsg
*/
public static function getIndexedCount(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -554,7 +554,7 @@ class ManticoreMsg
*/
public static function updateDialogAllowedUsers(int $dialogId): int
{
if (!Apps::isInstalled("manticore") || $dialogId <= 0) {
if (!Apps::isInstalled("search") || $dialogId <= 0) {
return 0;
}

View File

@ -45,7 +45,7 @@ class ManticoreProject
return [];
}
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return [];
}
@ -130,7 +130,7 @@ class ManticoreProject
*/
public static function sync(Project $project, bool $withVector = false): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -205,7 +205,7 @@ class ManticoreProject
*/
public static function batchSync(iterable $projects, bool $withVector = false): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -226,7 +226,7 @@ class ManticoreProject
*/
public static function delete(int $projectId): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -240,7 +240,7 @@ class ManticoreProject
*/
public static function clear(): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -254,7 +254,7 @@ class ManticoreProject
*/
public static function getIndexedCount(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -274,7 +274,7 @@ class ManticoreProject
*/
public static function updateAllowedUsers(int $projectId): bool
{
if (!Apps::isInstalled("manticore") || $projectId <= 0) {
if (!Apps::isInstalled("search") || $projectId <= 0) {
return false;
}
@ -301,7 +301,7 @@ class ManticoreProject
*/
public static function generateVectorsBatch(array $projectIds, int $batchSize = 20): int
{
if (!Apps::isInstalled("manticore") || !Apps::isInstalled("ai") || empty($projectIds)) {
if (!Apps::isInstalled("search") || !Apps::isInstalled("ai") || empty($projectIds)) {
return 0;
}

View File

@ -61,7 +61,7 @@ class ManticoreTask
return [];
}
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return [];
}
@ -201,7 +201,7 @@ class ManticoreTask
*/
public static function sync(ProjectTask $task, bool $withVector = false): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -348,7 +348,7 @@ class ManticoreTask
*/
public static function batchSync(iterable $tasks, bool $withVector = false): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -369,7 +369,7 @@ class ManticoreTask
*/
public static function delete(int $taskId): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -383,7 +383,7 @@ class ManticoreTask
*/
public static function clear(): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -397,7 +397,7 @@ class ManticoreTask
*/
public static function getIndexedCount(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -417,7 +417,7 @@ class ManticoreTask
*/
public static function updateAllowedUsers(int $taskId): bool
{
if (!Apps::isInstalled("manticore") || $taskId <= 0) {
if (!Apps::isInstalled("search") || $taskId <= 0) {
return false;
}
@ -444,7 +444,7 @@ class ManticoreTask
*/
public static function cascadeUpdateByProject(int $projectId): int
{
if (!Apps::isInstalled("manticore") || $projectId <= 0) {
if (!Apps::isInstalled("search") || $projectId <= 0) {
return 0;
}
@ -493,7 +493,7 @@ class ManticoreTask
*/
public static function cascadeToChildren(int $taskId): void
{
if (!Apps::isInstalled("manticore") || $taskId <= 0) {
if (!Apps::isInstalled("search") || $taskId <= 0) {
return;
}
@ -526,7 +526,7 @@ class ManticoreTask
*/
public static function generateVectorsBatch(array $taskIds, int $batchSize = 20): int
{
if (!Apps::isInstalled("manticore") || !Apps::isInstalled("ai") || empty($taskIds)) {
if (!Apps::isInstalled("search") || !Apps::isInstalled("ai") || empty($taskIds)) {
return 0;
}

View File

@ -41,7 +41,7 @@ class ManticoreUser
return [];
}
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return [];
}
@ -131,7 +131,7 @@ class ManticoreUser
*/
public static function sync(User $user, bool $withVector = false): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -221,7 +221,7 @@ class ManticoreUser
*/
public static function batchSync(iterable $users, bool $withVector = false): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -242,7 +242,7 @@ class ManticoreUser
*/
public static function delete(int $userid): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -256,7 +256,7 @@ class ManticoreUser
*/
public static function clear(): bool
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return false;
}
@ -270,7 +270,7 @@ class ManticoreUser
*/
public static function getIndexedCount(): int
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return 0;
}
@ -291,7 +291,7 @@ class ManticoreUser
*/
public static function generateVectorsBatch(array $userIds, int $batchSize = 20): int
{
if (!Apps::isInstalled("manticore") || !Apps::isInstalled("ai") || empty($userIds)) {
if (!Apps::isInstalled("search") || !Apps::isInstalled("ai") || empty($userIds)) {
return 0;
}

View File

@ -18,7 +18,7 @@ class WebSocketDialogMsgObserver extends AbstractObserver
public function created(WebSocketDialogMsg $webSocketDialogMsg)
{
// Manticore 同步(仅在安装 Manticore 且符合索引条件时)
if (Apps::isInstalled('manticore') && ManticoreMsg::shouldIndex($webSocketDialogMsg)) {
if (Apps::isInstalled('search') && ManticoreMsg::shouldIndex($webSocketDialogMsg)) {
self::taskDeliver(new ManticoreSyncTask('msg_sync', ['msg_id' => $webSocketDialogMsg->id]));
}
}
@ -32,7 +32,7 @@ class WebSocketDialogMsgObserver extends AbstractObserver
public function updated(WebSocketDialogMsg $webSocketDialogMsg)
{
// Manticore 同步(更新可能使消息符合或不再符合索引条件,由 sync 方法处理)
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
self::taskDeliver(new ManticoreSyncTask('msg_sync', ['msg_id' => $webSocketDialogMsg->id]));
}
}
@ -46,7 +46,7 @@ class WebSocketDialogMsgObserver extends AbstractObserver
public function deleted(WebSocketDialogMsg $webSocketDialogMsg)
{
// Manticore 删除
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
self::taskDeliver(new ManticoreSyncTask('msg_delete', ['msg_id' => $webSocketDialogMsg->id]));
}
}
@ -71,7 +71,7 @@ class WebSocketDialogMsgObserver extends AbstractObserver
public function forceDeleted(WebSocketDialogMsg $webSocketDialogMsg)
{
// Manticore 删除
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
self::taskDeliver(new ManticoreSyncTask('msg_delete', ['msg_id' => $webSocketDialogMsg->id]));
}
}

View File

@ -34,7 +34,7 @@ class WebSocketDialogUserObserver extends AbstractObserver
Deleted::forget('dialog', $webSocketDialogUser->dialog_id, $webSocketDialogUser->userid);
// Manticore: 更新对话下所有消息的 allowed_users
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
self::taskDeliver(new ManticoreSyncTask('update_dialog_allowed_users', [
'dialog_id' => $webSocketDialogUser->dialog_id
]));
@ -69,7 +69,7 @@ class WebSocketDialogUserObserver extends AbstractObserver
Deleted::record('dialog', $webSocketDialogUser->dialog_id, $webSocketDialogUser->userid);
// Manticore: 更新对话下所有消息的 allowed_users
if (Apps::isInstalled('manticore')) {
if (Apps::isInstalled('search')) {
self::taskDeliver(new ManticoreSyncTask('update_dialog_allowed_users', [
'dialog_id' => $webSocketDialogUser->dialog_id
]));

View File

@ -70,7 +70,7 @@ class ManticoreSyncTask extends AbstractTask
public function start()
{
if (!Apps::isInstalled("manticore")) {
if (!Apps::isInstalled("search")) {
return;
}