Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/main/java/com/ly/ckibana/strategy/aggs/TermsAggStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,17 @@ public CkRequest buildCkRequest(CkRequestContext ckRequestContext) {
if (getSize() == null) {
setSize(10);
}
//若子aggs的有额外group by条件,size条件失效
if (isSubAggGroupByEmpty()) {
result.limit(getSize());

// 对于特殊的聚合组合(terms+子terms, range+子terms),应用 ES API 的 size 限制
// 其他复杂嵌套场景仍使用 maxResultRow 保证数据完整性
if (isSubAggGroupByEmpty() || isIgnoreSubAggCondition()) {
int actualLimit = getSize();
if (ckRequestContext.getMaxResultRow() > 0) {
actualLimit = Math.min(getSize(), ckRequestContext.getMaxResultRow());
}
result.limit(actualLimit);
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private String generateRangeSql() {
return String.format(LOGICALOP_RANGE_TEMPLATE_DEFAULT,
logicalOp,
SqlUtils.getCompareSql(field.getCkName(), includeThreshold ? Constants.Symbol.GTE : Constants.Symbol.GT, from),
SqlUtils.getCompareSql(field.getCkName(), includeThreshold ? Constants.Symbol.LTE : Constants.Symbol.GT, to));
SqlUtils.getCompareSql(field.getCkName(), includeThreshold ? Constants.Symbol.LTE : Constants.Symbol.LT, to));
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/ly/ckibana/util/ProxyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,11 @@ public static Range getRangeWrappedBySqlFunction(Range orgRange, boolean isTimeF
rangeConverted.setHigh(generateTimeFieldSqlWithFormatDateTime64ZoneShangHai(orgRange.getHigh(), ckFieldType));
rangeConverted.setLow(generateTimeFieldSqlWithFormatDateTime64ZoneShangHai(orgRange.getLow(), ckFieldType));
} else {
//ip
IPType ipType = ProxyUtils.getIpType(orgRange.getCkFieldType(), orgRange.getLow().toString());
//ip - 优先使用low值判断IP类型,如果low为null则使用high值
IPType ipType = null;
if (orgRange.getLow() != null) {
ipType = ProxyUtils.getIpType(orgRange.getCkFieldType(), orgRange.getLow().toString());
}
if (null != ipType) {
rangeConverted.setCkFieldName(SqlUtils.generateIpSql(ckFieldName, ipType, false));
rangeConverted.setHigh(SqlUtils.generateIpSql(orgRange.getHigh(), ipType, true));
Expand Down