Skip to content

Commit

Permalink
fix(基础模块): 修复es查询返回array类型数据转换错误问题.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Mar 12, 2024
1 parent 121c065 commit 0074468
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetlinks.community.elastic.search.utils;

import com.google.common.collect.Collections2;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.hswebframework.ezorm.core.param.QueryParam;
import org.jetlinks.community.elastic.search.index.ElasticSearchIndexMetadata;
Expand All @@ -8,10 +9,7 @@
import org.jetlinks.core.metadata.PropertyMetadata;
import org.jetlinks.core.metadata.types.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

public class ElasticSearchConverter {

Expand Down Expand Up @@ -74,6 +72,13 @@ public static Map<String, Object> convertDataFromElastic(Map<String, Object> dat
} else if (type instanceof DateTimeType) {
Date date = ((DateTimeType) type).convert(val);
newData.put(property.getId(), date);
} else if (type instanceof ObjectType) {
if (val instanceof Collection) {
val = Collections2.transform(((Collection<?>) val), ((ObjectType) type)::convert);
newData.put(property.getId(), val);
} else {
newData.put(property.getId(), ((ObjectType) type).convert(val));
}
} else if (type instanceof Converter) {
newData.put(property.getId(), ((Converter<?>) type).convert(val));
}
Expand Down

0 comments on commit 0074468

Please sign in to comment.