|
|
@ -37,8 +37,6 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
@Autowired |
|
|
|
private BFDApiConfig bfdApiConfig; |
|
|
|
@Autowired |
|
|
|
private ClusterService clusterService; |
|
|
|
@Autowired |
|
|
|
private EsCommonService esCommonService; |
|
|
|
@Autowired |
|
|
|
private ESServerUtils esServerUtils; |
|
|
@ -92,6 +90,7 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
logger.info("[SearchDataService] parseQueryResult ERROR !"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 遍历查询结果调用解析组装方法 2 用户信息的组装用的是这个方法!!! |
|
|
|
*/ |
|
|
@ -592,12 +591,10 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
List<String> currentIndexList = new ArrayList<>(); |
|
|
|
String subjectId = queryRequest.getSubjectId(); |
|
|
|
if (null != queryRequest.getSubjectId() && !("").equals(subjectId)) { // 如果是专题,去专题的索引查就行 |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 |
|
|
|
subjectId = cluster.getPrefixIndexPattern() +"_"+ subjectId; |
|
|
|
subjectId =bfdApiConfig.getIndexNamePre() + subjectId; |
|
|
|
currentIndexList.add(subjectId); |
|
|
|
} else { // 如果是全部数据,就直接去 渠道对应的索引查,渠道可以从 docId 中截取出来 |
|
|
|
logger.info("[SearchDataService] queryComment: 查询 全局数据"); |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.normal_cluster_type); // 109 |
|
|
|
String docId = queryRequest.getDocId(); |
|
|
|
String indexType = "cl_index_" + docId.split("_")[1]; |
|
|
|
currentIndexList.add(indexType); |
|
|
@ -705,6 +702,7 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据docId 查询一条数据的详情及评论列表 |
|
|
|
* |
|
|
|
* @param queryRequest |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -715,11 +713,9 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
List<String> currentIndexList = new ArrayList<>(); |
|
|
|
String subjectId = queryRequest.getSubjectId(); |
|
|
|
if (!("").equals(subjectId) && null != subjectId) { // 如果是专题,去专题的索引查就行 |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 |
|
|
|
subjectId = cluster.getPrefixIndexPattern() +"_"+ subjectId; |
|
|
|
subjectId = bfdApiConfig.getIndexNamePre() + subjectId; |
|
|
|
} else { // 如果是全部数据,就直接去 渠道对应的索引查,渠道可以从 docId 中截取出来 |
|
|
|
logger.info("[SearchDataService] queryOneDataByDocId 查询 全局数据 : {}", subjectId); |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.normal_cluster_type); // 109 |
|
|
|
} |
|
|
|
currentIndexList.add(subjectId); |
|
|
|
String docId = queryRequest.getDocId(); |
|
|
@ -767,8 +763,6 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 崔老师那个版本,需要添加 分类标签和 价值标签 |
|
|
|
private JSONObject setLable(JSONObject jsonObject) { |
|
|
|
if (!jsonObject.containsKey(ESConstant.VALUELABEL) || null == jsonObject.get(ESConstant.VALUELABEL)) { |
|
|
@ -875,7 +869,8 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
System.out.println("本次查询结果条数:" + searchDataResponse.getHits().totalHits); |
|
|
|
if (searchDataResponse.getHits().getHits().length > 0) { |
|
|
|
Map<String, Object> result = searchDataResponse.getHits().getHits()[0].getSourceAsMap(); |
|
|
|
if (result.size() > 0) { result.entrySet().stream() |
|
|
|
if (result.size() > 0) { |
|
|
|
result.entrySet().stream() |
|
|
|
.forEach(entry -> { |
|
|
|
if (entry.getKey().equals(ESConstant.FILEPATH) && entry.getValue().equals("")) { |
|
|
|
jsonObject.put(entry.getKey(), new ArrayList<>()); |
|
|
@ -912,8 +907,8 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
List<String> currentIndexList = new ArrayList<>(); |
|
|
|
// 获取ES的参数及要查询的索引列表 |
|
|
|
String subjectId = queryRequest.getSubjectId(); |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 special_cluster_type |
|
|
|
currentIndexList = subjectQueryDataService.getIndexBySubjectIds(cluster,subjectId); |
|
|
|
// cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 special_cluster_type |
|
|
|
currentIndexList = subjectQueryDataService.getIndexBySubjectIds(subjectId); |
|
|
|
Long clusterId = cluster.getId(); |
|
|
|
logger.info("[SearchDataService] queryDataList clusterId : {}; currentIndexList : {}", clusterId, currentIndexList.toString()); |
|
|
|
|
|
|
@ -994,10 +989,10 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
public JSONObject queryDataInOneIndex(QueryRequest queryRequest) { |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
try { |
|
|
|
Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds(cluster, queryRequest.getSubjectId()); |
|
|
|
Long clusterId = cluster.getId(); |
|
|
|
logger.info("[SearchDataService] queryDataInOneIndex: clusterId :{} ; currentIndexList : {}", clusterId,currentIndexList.toString()); |
|
|
|
// Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds( queryRequest.getSubjectId()); |
|
|
|
//Long clusterId = cluster.getId(); |
|
|
|
logger.info("[SearchDataService] queryDataInOneIndex: currentIndexList : {}", currentIndexList.toString()); |
|
|
|
// String indexName = currentIndexList.get(0); |
|
|
|
String indexNames[] = currentIndexList.toArray(new String[currentIndexList.size()]); |
|
|
|
List<JSONObject> dataList = esQueryServiceForSQMini.queryDataFromOneSubject(indexNames, queryRequest); |
|
|
@ -1018,6 +1013,7 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出专题下数据调用的方法 |
|
|
|
* |
|
|
|
* @param queryRequest |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -1025,11 +1021,11 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
try { |
|
|
|
// 获取 ES 的连接方式及要查询的索引列表 专题索引 special_cluster_type |
|
|
|
Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds(cluster, queryRequest.getSubjectId()); |
|
|
|
Long clusterId = cluster.getId(); |
|
|
|
//Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds( queryRequest.getSubjectId()); |
|
|
|
// Long clusterId = cluster.getId(); |
|
|
|
String[] indexName = currentIndexList.toArray(new String[currentIndexList.size()]); |
|
|
|
logger.info("[SearchDataService] exportDataInSubjectIndex : IndexName :{} ; clusterId :{} ; currentIndexList :{}",indexName[0], clusterId , currentIndexList.toString()); |
|
|
|
logger.info("[SearchDataService] exportDataInSubjectIndex : IndexName :{} ; currentIndexList :{}", indexName[0], currentIndexList.toString()); |
|
|
|
// 开始查询 |
|
|
|
jsonObject = esQueryServiceForSQMini.exportDataFromOneSubject(indexName, queryRequest); |
|
|
|
List<JSONObject> dataList = (List<JSONObject>) jsonObject.get(ESConstant.MONITORLISTS); |
|
|
@ -1047,11 +1043,11 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
try { |
|
|
|
// 获取 ES 的连接方式及要查询的索引列表 |
|
|
|
Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 专题索引 special_cluster_type |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds(cluster, queryRequest.getSubjectId()); |
|
|
|
Long clusterId = cluster.getId(); |
|
|
|
// Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 专题索引 special_cluster_type |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds( queryRequest.getSubjectId()); |
|
|
|
// Long clusterId = cluster.getId(); |
|
|
|
String[] indexName = currentIndexList.toArray(new String[currentIndexList.size()]); |
|
|
|
logger.info("[SearchDataService] exportDataInSubjectIndex : IndexName :{} ; clusterId :{} ; currentIndexList :{}",indexName[0], clusterId , currentIndexList.toString()); |
|
|
|
logger.info("[SearchDataService] exportDataInSubjectIndex : IndexName :{} ; currentIndexList :{}", indexName[0], currentIndexList.toString()); |
|
|
|
jsonObject = esQueryServiceForSQMini.exportDataFromOneSubject(indexName, queryRequest); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
@ -1067,11 +1063,11 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
// 获取ES的参数及要查询的索引列表 |
|
|
|
String subjectId = queryRequest.getSubjectId(); |
|
|
|
if (subjectId.equals("all")) { |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.normal_cluster_type); // 109 |
|
|
|
currentIndexList = subjectQueryDataService.getIndexListByTimeRange(cluster, queryRequest.getStartTime(), queryRequest.getEndTime()); |
|
|
|
// cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.normal_cluster_type); // 109 |
|
|
|
// currentIndexList = subjectQueryDataService.getIndexListByTimeRange(queryRequest.getStartTime(), queryRequest.getEndTime()); |
|
|
|
} else if (subjectId.contains(",")) { |
|
|
|
cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 |
|
|
|
currentIndexList = subjectQueryDataService.getIndexBySubjectIds(cluster, queryRequest.getSubjectId()); |
|
|
|
// cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 |
|
|
|
currentIndexList = subjectQueryDataService.getIndexBySubjectIds( queryRequest.getSubjectId()); |
|
|
|
} |
|
|
|
Long clusterId = cluster.getId(); |
|
|
|
logger.info("[SearchDataService] exportDataInOneIndex: clusterId :{}; currentIndexList : {}", clusterId, currentIndexList.toString()); |
|
|
@ -1091,12 +1087,9 @@ public class SearchDataService extends CrudService<SentimentModify, SentimentRep |
|
|
|
public JSONObject queryDataCountsInOneIndex(QueryRequest queryRequest) { |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
try { |
|
|
|
Cluster cluster = clusterService.findClusterByType(Cluster.CLUSTER_TYPE.special_cluster_type); // 111 special_cluster_type |
|
|
|
List<String> currentIndexList = subjectQueryDataService.getIndexBySubjectIds(cluster, queryRequest.getSubjectId()); |
|
|
|
Long clusterId = cluster.getId(); |
|
|
|
logger.info("[SearchDataService] queryDataCountsInOneIndex: clusterId : {}; currentIndexList : {}" , clusterId ,currentIndexList.toString()); |
|
|
|
// String indexName = currentIndexList.get(0); |
|
|
|
String indexNames [] = currentIndexList.toArray(new String [currentIndexList.size()]); |
|
|
|
String subjectId = queryRequest.getSubjectId(); |
|
|
|
String indexName = bfdApiConfig.getIndexNamePre()+subjectId; |
|
|
|
String indexNames[] = {indexName}; |
|
|
|
Long contentCount = 0L; |
|
|
|
Long commentCount = 0L; |
|
|
|
Long authorCount = 0L; |
|
|
|