|
|
@@ -676,19 +676,27 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
// 调用向量搜索接口,topN 取 pageSize 的合理上限
|
|
|
int topN = Math.min(pageSize, 50);
|
|
|
JSONObject data = managerApiService.recallVideoWithScore(param.getTitle(), topN);
|
|
|
- if (data == null) {
|
|
|
- result.setTotalSize(0);
|
|
|
- result.setObjs(new ArrayList<>());
|
|
|
- return result;
|
|
|
+
|
|
|
+ boolean vectorEmpty = (data == null);
|
|
|
+ if (!vectorEmpty) {
|
|
|
+ JSONArray items = data.getJSONArray("items");
|
|
|
+ vectorEmpty = (items == null || items.isEmpty());
|
|
|
}
|
|
|
|
|
|
- JSONArray items = data.getJSONArray("items");
|
|
|
- if (items == null || items.isEmpty()) {
|
|
|
- result.setTotalSize(0);
|
|
|
- result.setObjs(new ArrayList<>());
|
|
|
- return result;
|
|
|
+ // 向量搜索为空,降级走关键词搜索
|
|
|
+ if (vectorEmpty) {
|
|
|
+ Page<VideoContentItemVO> fallbackResult = getVideoContentListByTitle(param);
|
|
|
+ // 标识来源为关键词搜索
|
|
|
+ if (fallbackResult.getObjs() != null) {
|
|
|
+ for (VideoContentItemVO vo : fallbackResult.getObjs()) {
|
|
|
+ vo.setSearchSource("manager");
|
|
|
+ vo.setExperimentId("manager_search");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fallbackResult;
|
|
|
}
|
|
|
|
|
|
+ JSONArray items = data.getJSONArray("items");
|
|
|
int total = data.getIntValue("total");
|
|
|
int effectiveTotalSize = Math.min(total, videoTitleSearchMaxCount);
|
|
|
result.setTotalSize(effectiveTotalSize);
|
|
|
@@ -746,6 +754,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
VideoContentItemVO vo = new VideoContentItemVO();
|
|
|
vo.setVideoId(videoId);
|
|
|
vo.setScore(item.getDouble("score"));
|
|
|
+ // 标识来源为向量搜索
|
|
|
+ vo.setSearchSource("vector");
|
|
|
+ vo.setExperimentId("vector_search");
|
|
|
// 优先从视频详情中获取标题、封面、视频地址
|
|
|
VideoDetail detail = videoDetailMap.get(videoId);
|
|
|
if (detail != null) {
|