Skip to content

Commit e1e2891

Browse files
author
hemiao
committed
es查询 includes 与解析
1 parent f05867e commit e1e2891

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

moql-querier/src/main/java/org/datayoo/moql/querier/es/EsDataQuerier.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ protected void transformSelectorDefinition(
151151

152152
private List<ColumnMetadata> getIndexColumnsMetadata(String indexName)
153153
throws IOException {
154-
String[] indexNameArray = StringUtils.split(indexName,",");
154+
String[] indexNameArray = StringUtils.split(indexName, ",");
155155
List<String> columnNames = new ArrayList<>();
156-
for (String index: indexNameArray) {
156+
for (String index : indexNameArray) {
157157
Request request = new Request("GET", index);
158158
Response response = httpClient.performRequest(request);
159159
String data = EntityUtils.toString(response.getEntity());
160160
JsonParser jsonParser = new JsonParser();
161161
JsonObject root = (JsonObject) jsonParser.parse(data);
162-
JsonObject properties = root.get(index).getAsJsonObject()
163-
.get("mappings").getAsJsonObject().get("properties").getAsJsonObject();
162+
JsonObject properties = root.get(index).getAsJsonObject().get("mappings")
163+
.getAsJsonObject().get("properties").getAsJsonObject();
164164

165165
properties.entrySet();
166166
for (Map.Entry<String, JsonElement> map : properties.entrySet()) {
@@ -337,8 +337,8 @@ protected Operand[] buildColumnOperands(
337337
String value = columnMetadata.getValue();
338338
int index = value.indexOf('(');
339339
if (index == -1) {
340-
index = value.indexOf('.');
341-
value = value.substring(index + 1);
340+
// index = value.indexOf('.');
341+
// value = value.substring(index + 1);
342342
} else {
343343
value = getAggregationFunctionExpression(columnMetadata);
344344
}
@@ -370,6 +370,7 @@ protected EntityMap toQueryEntityMap(JsonObject jsonObject) {
370370
return new EntityMapImpl(record);
371371
}
372372

373+
373374
protected void toMap(JsonObject jsonObject, Map<String, Object> record) {
374375
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
375376
if (entry.getKey().equals("_source")) {
@@ -379,10 +380,7 @@ protected void toMap(JsonObject jsonObject, Map<String, Object> record) {
379380
Object value = entry.getValue();
380381
if (entry.getValue() instanceof JsonPrimitive) {
381382
value = getValue((JsonPrimitive) entry.getValue());
382-
} else {
383-
value = entry.getValue().toString();
384383
}
385-
386384
record.put(entry.getKey(), value);
387385
}
388386
}

moql-translator/src/main/java/org/datayoo/moql/sql/es/ElasticSearchTranslator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.apache.commons.lang3.Validate;
55
import org.datayoo.moql.*;
66
import org.datayoo.moql.core.*;
7+
import org.datayoo.moql.core.Column;
78
import org.datayoo.moql.core.group.GroupRecordSetOperator;
89
import org.datayoo.moql.metadata.*;
910
import org.datayoo.moql.operand.constant.StringConstant;
@@ -116,11 +117,11 @@ protected void translateSelectClause(SelectorDefinition selectorDefinition,
116117
throw new UnsupportedOperationException(
117118
"Unsupported nested selector in select clause!");
118119
String value = columnMetadata.getValue();
119-
int index = value.indexOf('(');
120-
if (index == -1) {
121-
index = value.indexOf('.');
122-
value = value.substring(index + 1);
123-
}
120+
// int index = value.indexOf('(');
121+
// if (index == -1) {
122+
// index = value.indexOf('.');
123+
// value = value.substring(index + 1);
124+
// }
124125
includes.add(value);
125126
}
126127
source.add("includes", includes);

0 commit comments

Comments
 (0)