Commit 3715611e authored by alex yao's avatar alex yao

feat: 知识库分片模糊查询

parent 32665adf
......@@ -61,7 +61,7 @@ public interface KnowledgeService {
/**
* 获取知识库分片
*/
GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, PagingInfo pagingInfo);
GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, String query, PagingInfo pagingInfo);
/**
* 开关知识库分片
......
......@@ -212,7 +212,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
@Override
public List<BizKnowledgeDocumentEntity> searchDocuments(String search, String trainStatus, List<Integer> kdIds, String memberId, PagingInfo pagingInfo) {
List<BizKnowledgeDocumentEntity> result = new ArrayList<>();
List<KnowledgeQueryItem> knowledgeQueryItems = bizKnowledgeDocumentService.searchKnowledge(search, trainStatus, memberId, null, kdIds, pagingInfo);
List<KnowledgeQueryItem> knowledgeQueryItems = bizKnowledgeDocumentService.searchKnowledge(search, trainStatus, memberId, null, kdIds, pagingInfo);
if (CollectionUtils.isNotEmpty(knowledgeQueryItems)) {
result = knowledgeQueryItems.stream().map(item -> {
BizKnowledgeDocumentEntity entity = new BizKnowledgeDocumentEntity();
......@@ -242,14 +242,14 @@ public class KnowledgeServiceImpl implements KnowledgeService {
}
@Override
public GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, PagingInfo pagingInfo) {
public GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, String query, PagingInfo pagingInfo) {
List<String> knowledgeIds = new ArrayList<>();
for (Integer kdId : kdIds) {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
String knowledgeId = bizKnowledgeDocumentEntity.getKnowledgeId();
knowledgeIds.add(knowledgeId);
}
return demandKnowledgeService.getKnowledgeChunkInfos(knowledgeIds, pagingInfo);
return demandKnowledgeService.getKnowledgeChunkInfos(knowledgeIds, query, pagingInfo);
}
@Override
......
......@@ -142,5 +142,5 @@ public interface KnowledgeRest extends BaseRest {
/**
* 获取知识库分片信息
*/
GetKnowledgeChunkInfoResult getChunks(@RequestParam List<Integer> kdIds, PagingInfo pagingInfo);
GetKnowledgeChunkInfoResult getChunks(@RequestParam List<Integer> kdIds, @RequestParam String query, PagingInfo pagingInfo);
}
......@@ -278,8 +278,8 @@ public class KnowledgeRestImpl implements KnowledgeRest {
}
@Override
public GetKnowledgeChunkInfoResult getChunks(List<Integer> kdIds, PagingInfo pagingInfo) {
public GetKnowledgeChunkInfoResult getChunks(List<Integer> kdIds, String query, PagingInfo pagingInfo) {
Assert.notEmpty(kdIds);
return knowledgeService.getChunkInfo(kdIds, pagingInfo);
return knowledgeService.getChunkInfo(kdIds, query, pagingInfo);
}
}
......@@ -40,9 +40,10 @@ public interface DemandKnowledgeService {
* 获取知识库分片
*
* @param knowledgeIds 知识库id
* @param pagingInfo 分页信息
* @param query 查询文本
* @param pagingInfo 分页信息
*/
GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, PagingInfo pagingInfo);
GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, String query, PagingInfo pagingInfo);
/**
* 开关知识库分片
......
......@@ -72,9 +72,10 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
}
@Override
public GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, PagingInfo pagingInfo) {
public GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, String query, PagingInfo pagingInfo) {
GetKnowledgeChunkInfoRequest request = new GetKnowledgeChunkInfoRequest();
request.setKnowledgeIds(knowledgeIds);
request.setQuery(query);
return dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.GET_KNOWLEDGE_CHUNK_INFOS, request, getHeaders(), pagingInfo);
}
......
......@@ -9,6 +9,8 @@ public class GetKnowledgeChunkInfoRequest extends AbstractRequest<GetKnowledgeCh
private List<String> knowledgeIds;
private String query;
public List<String> getKnowledgeIds() {
return knowledgeIds;
}
......@@ -17,6 +19,14 @@ public class GetKnowledgeChunkInfoRequest extends AbstractRequest<GetKnowledgeCh
this.knowledgeIds = knowledgeIds;
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
@Override
public String getMethod() throws Exception {
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment