This commit is contained in:
luke 2025-06-07 17:17:56 +08:00
parent a406696cfd
commit cb0883bcda
2 changed files with 10 additions and 3 deletions

3
config/redis/cmd.txt Normal file
View File

@ -0,0 +1,3 @@
# 获取redis中的key-value
redis-cli keys "kb*" | while read key; do echo "$key : $(redis-cli get "$key")"; done

View File

@ -2,8 +2,8 @@ package com.knowledge.base.infrastructure.north.controller;
import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONUtil;
import com.knowledge.base.infrastructure.cache.FileCacheService;
import com.knowledge.base.infrastructure.north.dto.SearchReq;
import com.knowledge.base.infrastructure.util.LocalCacheUtil;
import com.google.common.collect.Maps;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
@ -17,6 +17,7 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@ -36,6 +37,9 @@ public class SearchController {
private final RestHighLevelClient esClient;
@Autowired
private FileCacheService fileCacheService;
@Value("${search.default-page-size:10}")
private int defaultPageSize;
@ -92,8 +96,8 @@ public class SearchController {
List<String> fileNames = (List)req.get("fileNames");
Map<String, Object> filePaths = Maps.newHashMap();
fileNames.forEach(name -> {
if(LocalCacheUtil.get(name) != null) {
filePaths.put(name, LocalCacheUtil.get(name));
if(fileCacheService.getPath(name).isPresent()) {
filePaths.put(name, fileCacheService.getPath(name));
}
});
Map<String, Object> result = Maps.newHashMap();