|
|
@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
|
|
import org.springframework.data.elasticsearch.core.SearchHit;
|
|
|
@@ -69,19 +70,21 @@ public class ElasticSearchController {
|
|
|
String indexName = "docs_" + list.get(0).getSpaceId();
|
|
|
esConfig.setIndexName(indexName);
|
|
|
try {
|
|
|
-
|
|
|
- List<SearchHit<EsDocInfo>> all = esDocInfoService.findByContent(keyword, PageRequest.of(page, size, Sort.by(Sort.Order.desc("id"))));
|
|
|
+ Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("id")));
|
|
|
+ long total = esDocInfoService.countByContent(keyword);
|
|
|
+ List<SearchHit<EsDocInfo>> all = esDocInfoService.findByContent(keyword, pageable);
|
|
|
List<SearchHit<EsDocInfo>> result = new ArrayList<>();
|
|
|
if (all.size() > 0) {
|
|
|
for (SearchHit<EsDocInfo> re : all) {
|
|
|
EsDocInfo esDocInfo = re.getContent();
|
|
|
+ esDocInfo.setContent("");
|
|
|
DocInfo docInfo = infoService.selectDocInfoByDocId(esDocInfo.getId());
|
|
|
if (docInfo != null) {
|
|
|
esDocInfo.setDocInfo(docInfo);
|
|
|
result.add(re);
|
|
|
}
|
|
|
}
|
|
|
- return AjaxResult.success("查询成功", result);
|
|
|
+ return AjaxResult.success("查询成功", result).put("total", total);
|
|
|
} else {
|
|
|
return AjaxResult.success("无结果");
|
|
|
}
|