优化模型搜索返回结果 - 移除冗余字段

移除不必要的字段以简化API响应:
• 删除component_path字段,避免重复路径信息
• 删除display_name字段,model_name已足够
• 删除file_size和last_modified字段,减少响应体积
• 保留核心搜索功能,优化用户体验

JSON响应更简洁,只包含必要的搜索结果信息。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sladro 2025-08-28 18:47:34 +08:00
parent b874b17534
commit 00ddd48082
3 changed files with 1 additions and 17 deletions

View File

@ -125,7 +125,6 @@ void ModelSearchEngine::SearchSessionModels(const ModelSearchRequest& request, s
// Create search result item
SearchResultItem item;
item.model_name = model_name;
item.display_name = model_name;
item.full_path = model_name; // 对于会话中的根模型,路径就是模型名
item.file_path = file_path; // 物理文件路径
item.model_type = model_type;
@ -202,7 +201,6 @@ void ModelSearchEngine::SearchFromRootAssemblies(const ModelSearchRequest& reque
if (match_score >= request.similarity_threshold) {
SearchResultItem item;
item.model_name = root_name;
item.display_name = root_name;
item.full_path = root_name; // Root assembly path
item.file_path = GetModelFilePath(model);
item.model_type = "ASSEMBLY";
@ -275,7 +273,6 @@ void ModelSearchEngine::SearchCurrentModel(const ModelSearchRequest& request, st
SearchResultItem item;
item.model_name = model_name;
item.display_name = model_name;
item.full_path = model_name; // 当前模型的路径就是模型名
item.file_path = file_path; // 物理文件路径
item.model_type = GetModelTypeString(current_model);
@ -385,11 +382,9 @@ void ModelSearchEngine::SearchAssemblyComponents(const ModelSearchRequest& reque
if (match_score >= request.similarity_threshold) {
SearchResultItem item;
item.model_name = comp_name;
item.display_name = comp_name;
item.full_path = tree_path; // Model tree hierarchy path
item.file_path = comp_file; // Physical file path
item.model_type = model_type;
item.component_path = BuildComponentPath(parent_path, comp_name);
item.match_score = match_score;
item.match_type = "component";
item.is_in_session = true;
@ -502,11 +497,9 @@ void ModelSearchEngine::SearchAssemblyComponentsWithDedup(const ModelSearchReque
if (match_score >= request.similarity_threshold) {
SearchResultItem item;
item.model_name = comp_name;
item.display_name = comp_name;
item.full_path = tree_path; // Model tree hierarchy path
item.file_path = comp_file; // Physical file path
item.model_type = model_type;
item.component_path = BuildComponentPath(parent_path, comp_name);
item.match_score = match_score;
item.match_type = "component";
item.is_in_session = true;

View File

@ -48,21 +48,15 @@ struct ModelSearchRequest {
// 搜索结果项结构
struct SearchResultItem {
std::string model_name; // 模型名称
std::string display_name; // 显示名称
std::string full_path; // 模型树中的完整路径
std::string file_path; // 文件路径 (GetOrigin)
std::string model_type; // 模型类型 ("PART", "ASSEMBLY", "DRAWING")
std::string component_path; // 组件路径(装配体中的位置)
double match_score; // 匹配分数 (0.0-1.0)
std::string match_reason; // 匹配原因说明
std::string match_type; // 匹配类型 ("name", "component", "feature")
bool is_in_session; // 是否在当前会话中
bool is_assembly; // 是否是装配体
int component_count; // 组件数量(装配体)
// 扩展信息
std::string file_size; // 文件大小
std::string last_modified; // 最后修改时间
std::vector<std::string> matched_keywords; // 匹配的关键词
// 构造函数

View File

@ -123,18 +123,15 @@ HttpResponse ModelSearchHandler::FormatSuccessResponse(const ModelSearchResult&
json << "{"
<< "\"model_name\": \"" << EscapeJsonString(item.model_name) << "\","
<< "\"display_name\": \"" << EscapeJsonString(item.display_name) << "\","
<< "\"full_path\": \"" << EscapeJsonString(item.full_path) << "\","
<< "\"file_path\": \"" << EscapeJsonString(item.file_path) << "\","
<< "\"model_type\": \"" << EscapeJsonString(item.model_type) << "\","
<< "\"component_path\": \"" << EscapeJsonString(item.component_path) << "\","
<< "\"match_score\": " << item.match_score << ","
<< "\"match_reason\": \"" << EscapeJsonString(item.match_reason) << "\","
<< "\"match_type\": \"" << EscapeJsonString(item.match_type) << "\","
<< "\"is_in_session\": " << (item.is_in_session ? "true" : "false") << ","
<< "\"is_assembly\": " << (item.is_assembly ? "true" : "false") << ","
<< "\"component_count\": " << item.component_count << ","
<< "\"file_size\": \"" << EscapeJsonString(item.file_size) << "\","
<< "\"last_modified\": \"" << EscapeJsonString(item.last_modified) << "\","
<< "\"matched_keywords\": [";
// Build matched keywords list