Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:indexpattern fields 支持string类型ck字段.keyword返回。支持DSL filter使用方式下精确筛选功能 #59

Merged
merged 1 commit into from
Aug 1, 2024
Merged
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
20 changes: 18 additions & 2 deletions src/main/java/com/ly/ckibana/parser/ParamParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ public Map<String, JSONObject> queryIndexPatternFields(RequestContext requestCon
Map<String, JSONObject> result = new HashMap<>();
String tableName = indexPattern.getIndex();
Map<String, String> columns = ckService.queryColumns(requestContext.getProxyConfig().getCkDatasource(), tableName);
//特殊查询字段不存在,转为真实对应的ck字段
for (Map.Entry<String, String> each : columns.entrySet()) {
String ckName = each.getKey();
String ckType = each.getValue();
Expand All @@ -276,11 +275,28 @@ public Map<String, JSONObject> queryIndexPatternFields(RequestContext requestCon
isNotIndexPatternTimeField(indexPattern, ckName) ? Boolean.FALSE : isForSelectTimeField);
JSONObject jsonObjectType = new JSONObject();
jsonObjectType.put(esType, new IndexPatternFields(ckName, esType));
result.put(ckName, jsonObjectType);
//string类额外支持.keyword字段返回
if (ProxyUtils.isString(ckType)) {
addOneField(ckName + Constants.ES_KEYWORD, esType, result);
}
addOneField(ckName, esType, result);
}
return result;
}

/**
* 添加一个字段到indexPattern fields返回结果
*
* @param name
* @param type
* @param fields
*/
private static void addOneField(String name, String type, Map<String, JSONObject> fields) {
JSONObject fieldObject = new JSONObject();
fieldObject.put(type, new IndexPatternFields(name, type));
fields.put(name, fieldObject);
}

/**
* 是否命中已经被设置为时间字段的字段名.
*
Expand Down