From 0074468c291f4c5b952182874923e299a18ebdcf Mon Sep 17 00:00:00 2001 From: zhouhao Date: Tue, 12 Mar 2024 18:02:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9F=BA=E7=A1=80=E6=A8=A1=E5=9D=97):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Des=E6=9F=A5=E8=AF=A2=E8=BF=94=E5=9B=9Earray?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/utils/ElasticSearchConverter.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jetlinks-components/elasticsearch-component/src/main/java/org/jetlinks/community/elastic/search/utils/ElasticSearchConverter.java b/jetlinks-components/elasticsearch-component/src/main/java/org/jetlinks/community/elastic/search/utils/ElasticSearchConverter.java index c9d110aa..8c437b2c 100644 --- a/jetlinks-components/elasticsearch-component/src/main/java/org/jetlinks/community/elastic/search/utils/ElasticSearchConverter.java +++ b/jetlinks-components/elasticsearch-component/src/main/java/org/jetlinks/community/elastic/search/utils/ElasticSearchConverter.java @@ -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; @@ -8,10 +9,7 @@ import org.jetlinks.core.metadata.DataType; 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 { @@ -74,6 +72,13 @@ public class ElasticSearchConverter { } 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)); }