Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/es/index_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def build_somni_audio_materials_mapping(embedding_dim: int) -> dict[str, Any]:
"description_vector": f"description_text 的 {embedding_dim} 维 embedding",
"status": "是否启用;true 表示可参与检索与同步",
"audio_url": "音频文件 CDN / 对象存储 URL",
"cover_url": "封面图 CDN / 对象存储 URL",
"operation_type": "0 大模型打标,1 人工打标",
"tag_id": "标签 ID,关联 somni_audio_tag_dictionary._id",
"code": "标签编码,用于规则判断与接口传输",
Expand Down Expand Up @@ -98,6 +99,7 @@ def build_somni_audio_materials_mapping(embedding_dim: int) -> dict[str, Any]:
),
"status": _field("boolean", "是否启用;true 表示可参与检索与同步"),
"audio_url": _field("keyword", "音频文件地址(CDN / 对象存储 / 内部资源 URL)"),
"cover_url": _field("keyword", "封面图地址(CDN / 对象存储 / 内部资源 URL)"),
"operation_type": _field(
"integer",
"标注操作类型:0 大模型打标,1 人工打标",
Expand Down
1 change: 1 addition & 0 deletions app/es/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"audio_name",
"description",
"audio_url",
"cover_url",
"sleep_stage_tags",
"content_form_tags",
"mechanism_tags",
Expand Down
1 change: 1 addition & 0 deletions app/schemas/search_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def project_search_material(doc: dict[str, Any]) -> dict[str, Any]:
"audio_name": str(doc.get("audio_name") or ""),
"description": str(doc.get("description") or ""),
"audio_url": str(doc.get("audio_url") or ""),
"cover_url": str(doc.get("cover_url") or ""),
"content_form_tags": _project_content_form_tags(doc.get("content_form_tags")),
"audio_engineering_tags": _project_engineering_tags(
doc.get("audio_engineering_tags")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ async def test_search_returns_projected_material() -> None:
"audio_name": "雨声A",
"description": "描述",
"audio_url": doc["audio_url"],
"cover_url": "",
"content_form_tags": [{"name": "雨声", "parent_tag_id": "p1"}],
"audio_engineering_tags": [],
}
Expand Down Expand Up @@ -706,6 +707,7 @@ async def test_text_query_can_return_description_only_recall() -> None:
"audio_name": "描述命中",
"description": "海边声音",
"audio_url": "https://cdn.example.com/描述命中.mp3",
"cover_url": "",
"content_form_tags": [{"name": "海浪", "parent_tag_id": "p2"}],
"audio_engineering_tags": [],
}
Expand Down
10 changes: 10 additions & 0 deletions tests/test_search_material_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def test_project_keeps_only_api_fields() -> None:
"audio_name": "雨声",
"description": "轻柔雨声",
"audio_url": "https://cdn/a.mp3",
"cover_url": "https://cdn/a-cover.jpg",
"status": True,
"sleep_stage_tags": [{"tag_id": "s1", "name": "放松"}],
"mechanism_tags": [{"tag_id": "m1", "name": "放松"}],
Expand Down Expand Up @@ -39,6 +40,7 @@ def test_project_keeps_only_api_fields() -> None:
"audio_name": "雨声",
"description": "轻柔雨声",
"audio_url": "https://cdn/a.mp3",
"cover_url": "https://cdn/a-cover.jpg",
"content_form_tags": [{"name": "雨声", "parent_tag_id": "p1"}],
"audio_engineering_tags": [
{"code": "event_density", "value": {"code": "low"}}
Expand All @@ -60,3 +62,11 @@ def test_project_missing_value_is_null() -> None:
}
)
assert out["audio_engineering_tags"] == [{"code": "tempo", "value": None}]
assert out["cover_url"] == ""


def test_project_cover_url_empty_when_absent() -> None:
out = project_search_material(
{"_id": "1", "audio_name": "a", "audio_url": "u"}
)
assert out["cover_url"] == ""