diff --git a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/autoconfigure/ElasticsearchProperties.java b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/autoconfigure/ElasticsearchProperties.java index 8a04b3b..0aeebe3 100644 --- a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/autoconfigure/ElasticsearchProperties.java +++ b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/autoconfigure/ElasticsearchProperties.java @@ -1,6 +1,9 @@ package com.xkcoding.elasticsearch.autoconfigure; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/contants/DataTypeTransfer.java b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/contants/DataTypeTransfer.java deleted file mode 100644 index 7ff2e11..0000000 --- a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/contants/DataTypeTransfer.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.xkcoding.elasticsearch.contants; - -/** - * DataTypeTransfer - * - * @author fxbin - * @version 1.0v - * @since 2019/9/16 18:00 - */ -public enum DataTypeTransfer { -} diff --git a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/service/BaseElasticsearchService.java b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/service/BaseElasticsearchService.java index 1e64f01..9179de8 100644 --- a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/service/BaseElasticsearchService.java +++ b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/service/BaseElasticsearchService.java @@ -4,14 +4,12 @@ import com.xkcoding.elasticsearch.exception.ElasticsearchException; import com.xkcoding.elasticsearch.autoconfigure.ElasticsearchProperties; import com.xkcoding.elasticsearch.util.BeanUtils; import lombok.extern.slf4j.Slf4j; -import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.HttpAsyncResponseConsumerFactory; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; @@ -19,7 +17,6 @@ import org.elasticsearch.client.indices.CreateIndexRequest; import org.elasticsearch.client.indices.CreateIndexResponse; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.builder.SearchSourceBuilder; @@ -151,6 +148,8 @@ public abstract class BaseElasticsearchService { /** * search all + * + * @author fxbin * @param index elasticsearch index name * @return {@link SearchResponse} */ diff --git a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/util/BeanUtils.java b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/util/BeanUtils.java index ffc1bdb..6441634 100644 --- a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/util/BeanUtils.java +++ b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/util/BeanUtils.java @@ -1,7 +1,5 @@ package com.xkcoding.elasticsearch.util; -import com.xkcoding.elasticsearch.model.Person; - import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -17,36 +15,6 @@ import java.util.Map; */ public class BeanUtils { - /** - * Java Bean to Map - * - * @author fxbin - * @param object Object - * @return Map - */ - public static Map toFieldNameAndFieldTypeMap(Object object){ - Map map = MapUtils.newHashMap(); - try { - // 获取javaBean的BeanInfo对象 - BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass(),Object.class); - - // 获取属性描述器 - PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); - for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { - // 获取属性名 - String key = propertyDescriptor.getName(); - Class value = propertyDescriptor.getPropertyType(); - // 获取该属性的值 -// Method readMethod = propertyDescriptor.getReadMethod(); - // 通过反射来调用javaBean定义的getName()方法 -// Object value = readMethod.invoke(object); - map.put(key, value); - } - } catch (Exception e) { - e.printStackTrace(); - } - return map; - } /** * Java Bean to Map diff --git a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/resources/application.yml b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/resources/application.yml index 05aacad..640d066 100644 --- a/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/resources/application.yml +++ b/spring-boot-demo-elasticsearch-rest-high-level-client/src/main/resources/application.yml @@ -2,10 +2,7 @@ demo: data: elasticsearch: cluster-name: elasticsearch - cluster-nodes: 20.20.0.27:9201 + cluster-nodes: 20.20.0.27:9200 index: number-of-replicas: 0 number-of-shards: 3 - account: - username: - password: