|
@ -52,6 +52,8 @@ public class SolrExtract {
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
|
|
private static String create_date = "create_date";
|
|
|
|
|
|
private QuotaVo quotaVo;
|
|
private QuotaVo quotaVo;
|
|
private String startTime;
|
|
private String startTime;
|
|
private String endTime;
|
|
private String endTime;
|
|
@ -84,11 +86,14 @@ public class SolrExtract {
|
|
solrQuery.initParams(this.startTime, this.endTime);
|
|
solrQuery.initParams(this.startTime, this.endTime);
|
|
String core = esConfig.getTable(); // solr的core名
|
|
String core = esConfig.getTable(); // solr的core名
|
|
String q = null; // 过滤条件
|
|
String q = null; // 过滤条件
|
|
|
|
String createDateFilter = "";//入库时间过滤条件
|
|
// 统计数据数量
|
|
// 统计数据数量
|
|
String timeKey = esConfig.getTimekey();
|
|
String timeKey = esConfig.getTimekey();
|
|
if (!StringUtils.isEmpty(timeKey)) {
|
|
if (!StringUtils.isEmpty(timeKey)) {
|
|
if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
|
|
if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
|
|
q = String.format("%s:[%s TO %s]", timeKey, startTime, endTime);
|
|
q = String.format("%s:[%s TO %s]", timeKey, startTime, endTime);
|
|
|
|
createDateFilter = String.format("%s:[%s TO %s]", create_date, startTime, endTime);
|
|
|
|
q = q + " OR " + createDateFilter;
|
|
} else {
|
|
} else {
|
|
q = timeKey + ":[* TO *]";
|
|
q = timeKey + ":[* TO *]";
|
|
}
|
|
}
|
|
@ -105,6 +110,7 @@ public class SolrExtract {
|
|
String core = esConfig.getTable(); // solr的core名
|
|
String core = esConfig.getTable(); // solr的core名
|
|
String q = null; // 查询条件
|
|
String q = null; // 查询条件
|
|
String fq = null; // 过滤条件
|
|
String fq = null; // 过滤条件
|
|
|
|
String createDateFilter = "";//入库时间过滤条件
|
|
if (esConfig.getFilter() != null) {
|
|
if (esConfig.getFilter() != null) {
|
|
fq = esConfig.getFilter();
|
|
fq = esConfig.getFilter();
|
|
}
|
|
}
|
|
@ -145,7 +151,7 @@ public class SolrExtract {
|
|
dimensionGroupList.add(new SolrGroupEntity(key, SolrGroupEntity.GroupType.FIELD_VALUE));
|
|
dimensionGroupList.add(new SolrGroupEntity(key, SolrGroupEntity.GroupType.FIELD_VALUE));
|
|
fl += key + ",";
|
|
fl += key + ",";
|
|
}
|
|
}
|
|
fl += timeKey + ",rowkey";
|
|
|
|
|
|
fl += timeKey + "," + create_date + ",rowkey";
|
|
|
|
|
|
if (StringUtils.isEmpty(esConfig.getAggregation()) || (!esConfig.getAggregation().equals(Contant.quota.aggregation_list) && !esConfig.getAggregation().equals(Contant.quota.aggregation_distinct))) {
|
|
if (StringUtils.isEmpty(esConfig.getAggregation()) || (!esConfig.getAggregation().equals(Contant.quota.aggregation_list) && !esConfig.getAggregation().equals(Contant.quota.aggregation_distinct))) {
|
|
// 默认追加一个日期字段作为细维度,方便按天统计作为最小单位统计值。
|
|
// 默认追加一个日期字段作为细维度,方便按天统计作为最小单位统计值。
|
|
@ -161,6 +167,8 @@ public class SolrExtract {
|
|
if (!StringUtils.isEmpty(timeKey)) {
|
|
if (!StringUtils.isEmpty(timeKey)) {
|
|
if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
|
|
if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
|
|
q = String.format("%s:[%s TO %s]", timeKey, startTime, endTime);
|
|
q = String.format("%s:[%s TO %s]", timeKey, startTime, endTime);
|
|
|
|
createDateFilter = String.format("%s:[%s TO %s]", create_date, startTime, endTime);
|
|
|
|
q = q + " OR " + createDateFilter;
|
|
} else {
|
|
} else {
|
|
q = timeKey + ":[* TO *]";
|
|
q = timeKey + ":[* TO *]";
|
|
}
|
|
}
|