Browse Source

issue fixed

pull/1/head
fxbin Yangkai.Shen 5 years ago
parent
commit
bce3170c8c
5 changed files with 7 additions and 51 deletions
  1. +4
    -1
      spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/autoconfigure/ElasticsearchProperties.java
  2. +0
    -11
      spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/contants/DataTypeTransfer.java
  3. +2
    -3
      spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/service/BaseElasticsearchService.java
  4. +0
    -32
      spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/util/BeanUtils.java
  5. +1
    -4
      spring-boot-demo-elasticsearch-rest-high-level-client/src/main/resources/application.yml

+ 4
- 1
spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/autoconfigure/ElasticsearchProperties.java View File

@@ -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;



+ 0
- 11
spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/contants/DataTypeTransfer.java View File

@@ -1,11 +0,0 @@
package com.xkcoding.elasticsearch.contants;

/**
* DataTypeTransfer
*
* @author fxbin
* @version 1.0v
* @since 2019/9/16 18:00
*/
public enum DataTypeTransfer {
}

+ 2
- 3
spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/service/BaseElasticsearchService.java View File

@@ -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}
*/


+ 0
- 32
spring-boot-demo-elasticsearch-rest-high-level-client/src/main/java/com/xkcoding/elasticsearch/util/BeanUtils.java View File

@@ -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<String,Object> toFieldNameAndFieldTypeMap(Object object){
Map<String, Object> 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


+ 1
- 4
spring-boot-demo-elasticsearch-rest-high-level-client/src/main/resources/application.yml View File

@@ -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:

Loading…
Cancel
Save