|
@ -5,6 +5,8 @@ import com.yihu.ehr.controller.EnvelopRestEndPoint;
|
|
import com.yihu.ehr.hbase.HBaseDao;
|
|
import com.yihu.ehr.hbase.HBaseDao;
|
|
import com.yihu.ehr.profile.core.ResourceCore;
|
|
import com.yihu.ehr.profile.core.ResourceCore;
|
|
import com.yihu.ehr.profile.family.ResourceCells;
|
|
import com.yihu.ehr.profile.family.ResourceCells;
|
|
|
|
import com.yihu.ehr.resource.constants.MicroServiceApi;
|
|
|
|
import com.yihu.ehr.resource.service.ProfileSearchService;
|
|
import com.yihu.ehr.solr.SolrUtil;
|
|
import com.yihu.ehr.solr.SolrUtil;
|
|
import com.yihu.ehr.util.rest.Envelop;
|
|
import com.yihu.ehr.util.rest.Envelop;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@ -36,6 +38,8 @@ public class TextSearchEndPoint extends EnvelopRestEndPoint {
|
|
private SolrUtil solrUtil;
|
|
private SolrUtil solrUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private HBaseDao hBaseDao;
|
|
private HBaseDao hBaseDao;
|
|
|
|
@Autowired
|
|
|
|
private ProfileSearchService profileSearchService;
|
|
|
|
|
|
@ApiOperation(value = "全文检索")
|
|
@ApiOperation(value = "全文检索")
|
|
@RequestMapping(value = "/resources/text/search", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/resources/text/search", method = RequestMethod.GET)
|
|
@ -49,6 +53,8 @@ public class TextSearchEndPoint extends EnvelopRestEndPoint {
|
|
if (page == 0) {
|
|
if (page == 0) {
|
|
page ++;
|
|
page ++;
|
|
}
|
|
}
|
|
|
|
//更新热搜
|
|
|
|
profileSearchService.saveOrUpdateHotWords(keyword, 1);
|
|
Map<String, String> sortMap = new HashMap<>(1);
|
|
Map<String, String> sortMap = new HashMap<>(1);
|
|
sortMap.put(ResourceCells.EVENT_DATE, "desc");
|
|
sortMap.put(ResourceCells.EVENT_DATE, "desc");
|
|
QueryResponse queryResponse = solrUtil.highlight(ResourceCore.MasterTable, generateQ(keyword), null, sortMap, page - 1, size, ResourceCells.SEARCH_FIELD, null);
|
|
QueryResponse queryResponse = solrUtil.highlight(ResourceCore.MasterTable, generateQ(keyword), null, sortMap, page - 1, size, ResourceCells.SEARCH_FIELD, null);
|
|
@ -81,6 +87,27 @@ public class TextSearchEndPoint extends EnvelopRestEndPoint {
|
|
return success(dataList, (int)queryResponse.getResults().getNumFound(), page, size);
|
|
return success(dataList, (int)queryResponse.getResults().getNumFound(), page, size);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("获取热搜")
|
|
|
|
@RequestMapping(value = MicroServiceApi.ProfileSearch.Hotwords, method = RequestMethod.GET)
|
|
|
|
public List<String> getHotWords(
|
|
|
|
@ApiParam(name = "reCount", value = "返回个数", required = true)
|
|
|
|
@RequestParam(value = "reCount") int reCount,
|
|
|
|
@ApiParam(name = "type", value = "类型,1:病人档案热搜", required = true)
|
|
|
|
@RequestParam(value = "type") int type){
|
|
|
|
List<String> hotWords = profileSearchService.getHotWords(type,reCount);
|
|
|
|
return hotWords;
|
|
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("更新热搜")
|
|
|
|
@RequestMapping(value = MicroServiceApi.ProfileSearch.Hotwords, method = RequestMethod.POST)
|
|
|
|
public boolean updateHotWords(
|
|
|
|
@ApiParam(name = "searchText", value = "搜索关键词", required = true)
|
|
|
|
@RequestParam(value = "searchText") String searchText,
|
|
|
|
@ApiParam(name = "type", value = "类型,1:病人档案热搜", required = true)
|
|
|
|
@RequestParam(value = "type") int type){
|
|
|
|
return profileSearchService.saveOrUpdateHotWords(searchText,type);
|
|
|
|
}
|
|
|
|
|
|
private String generateQ(String keyword) {
|
|
private String generateQ(String keyword) {
|
|
if (StringUtils.isEmpty(keyword)) {
|
|
if (StringUtils.isEmpty(keyword)) {
|
|
return "*:*";
|
|
return "*:*";
|