|
|
@@ -283,7 +283,7 @@ public class MilvusServiceImpl implements IMilvusService {
|
|
283
|
283
|
milvusClient.loadCollection(loadCollectionReq);
|
|
284
|
284
|
QueryReq queryParam = QueryReq.builder()
|
|
285
|
285
|
.collectionName(collectionName)
|
|
286
|
|
- .filter("id > 0")
|
|
|
286
|
+ .filter("id > 0 && title != \"\"")
|
|
287
|
287
|
.outputFields(Arrays.asList("title"))
|
|
288
|
288
|
.build();
|
|
289
|
289
|
QueryResp queryResp = milvusClient.query(queryParam);
|
|
|
@@ -308,8 +308,8 @@ public class MilvusServiceImpl implements IMilvusService {
|
|
308
|
308
|
* 根据title名查询相关content
|
|
309
|
309
|
*/
|
|
310
|
310
|
@Override
|
|
311
|
|
- public List<String> listByTitle(String collectionName, String title) {
|
|
312
|
|
- List<String> contentList = new ArrayList<>();
|
|
|
311
|
+ public JSONArray listByTitle(String collectionName, String title) {
|
|
|
312
|
+ JSONArray resultArray = new JSONArray();
|
|
313
|
313
|
LoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()
|
|
314
|
314
|
.collectionName(collectionName)
|
|
315
|
315
|
.build();
|
|
|
@@ -317,24 +317,30 @@ public class MilvusServiceImpl implements IMilvusService {
|
|
317
|
317
|
QueryReq queryParam = QueryReq.builder()
|
|
318
|
318
|
.collectionName(collectionName)
|
|
319
|
319
|
.filter(String.format("title == \"%s\"", title))
|
|
320
|
|
- .outputFields(Arrays.asList("content"))
|
|
|
320
|
+ .outputFields(Arrays.asList("content", "file_name"))
|
|
321
|
321
|
.build();
|
|
322
|
322
|
QueryResp queryResp = milvusClient.query(queryParam);
|
|
323
|
323
|
List<QueryResp.QueryResult> rowRecordList;
|
|
324
|
324
|
if (queryResp != null) {
|
|
325
|
325
|
rowRecordList = queryResp.getQueryResults();
|
|
326
|
326
|
for (QueryResp.QueryResult rowRecord : rowRecordList) {
|
|
|
327
|
+ JSONObject item = new JSONObject();
|
|
327
|
328
|
Object content = rowRecord.getEntity().get("content");
|
|
|
329
|
+ Object fileName = rowRecord.getEntity().get("file_name");
|
|
328
|
330
|
if (content != null) {
|
|
329
|
|
- contentList.add(content.toString());
|
|
|
331
|
+ item.put("content", content.toString());
|
|
|
332
|
+ }
|
|
|
333
|
+ if (fileName != null) {
|
|
|
334
|
+ item.put("file_name", fileName.toString());
|
|
330
|
335
|
}
|
|
|
336
|
+ resultArray.add(item);
|
|
331
|
337
|
}
|
|
332
|
338
|
}
|
|
333
|
339
|
ReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()
|
|
334
|
340
|
.collectionName(collectionName)
|
|
335
|
341
|
.build();
|
|
336
|
342
|
milvusClient.releaseCollection(releaseCollectionReq);
|
|
337
|
|
- return contentList;
|
|
|
343
|
+ return resultArray;
|
|
338
|
344
|
}
|
|
339
|
345
|
|
|
340
|
346
|
}
|