spring-data-elasticsearch 创建geo_point 类型不生效

最近在用spring-data-elasticsearch 在做距离应用时创建geo_point
类型时发现有时候会不生效(注意是有时候不生效,不知道是哪里影响的,很妖),正常情况下type 应该是geo_point,但是有时候创建出来的是一个嵌套类型,包含两个double属性的type
实体类加了注解如下

@GeoPointField
private GeoPoint shipperPoint;

 创建出来的正确类型如下图:
 ![图片说明](https://img-ask.csdn.net/upload/201507/14/1436879872_437791.png)

创建出来的错误类型如下图:
图片说明
不知道是什么原因导致的geo_point 类型不生效?
求大神指导?

Chao_Nie
请叫我花先生 请问解决了吗,遇到了相同的问题,我写了一个TypeHandler将点信息转换为GeoPoint类型,使用@Document结合@GeoPointField注解,但是映射后的类型为两个float
6 个月之前 回复

4个回答

图片说明 这是正确类型

java model 属性如何定义为geo_point, 为什么我无法引入@GeoPointField,缺包吗?

请问lz是怎么解决的?我也出现了同样的问题。原因大概找到了:entity上的索引名称indexName是死的,而我需要动态的指定。当索引建好后,那个死的索引geo_point类型是正确的,而动态指定indexName的索引property类型确实错误的double(这种情况是查找不出来结果的)。就结果来说,和你的问题是一样的,请问这个是怎么解决的?

LYM0721
LYM0721 请问层主最后解决了吗?我碰到和层主一样的问题,动态指定index的时候geo_point类型无法正确设置。
10 个月之前 回复

参考http://es.xiaoleilu.com/310_Geopoints/20_Geopoints.html

地理坐标点不能被动态映射(dynamic mapping)自动检测,而是需要显式声明对应字段类型为 geo_point
先进行声明

PUT http://localhost:9200/my_index
{
"mappings": {
"my_type": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
然后实体映射就没有问题了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring-data-elasticsearch 字段如何驼峰转下划线
最近使用spring-data-elasticsearch,但是想在es中存储的时候使用下划线,请问各位大神有啥解决方案
java elasticsearch 属性如何定义为geo_point
java elasticsearch model属性如何定义为geo_point,@GeoPointField无法引入,是缺包吗。
一个关于spring-data-elasticSearch的问题
首先呢,我设置了一个model ``` @Data @Document(indexName = "myes2", type = "tt") public class MyEs2 implements Serializable { @Id @Field(type = FieldType.Long, store = true, index = false) private Long id; @Field(type = FieldType.Text, store = true, analyzer = "ik_max_word", searchAnalyzer = "ik_smart") private String title; @Field(type = FieldType.Text, store = true, analyzer = "ik_max_word", searchAnalyzer = "ik_smart") private String content; } ``` 可以看到ID我设置的是long类型,但是呢生成的mapping就变成了keyword ``` { "myes2": { "mappings": { "tt": { "properties": { "content": { "type": "text", "store": true, "analyzer": "ik_max_word", "search_analyzer": "ik_smart" }, "id": { "type": "keyword" }, "title": { "type": "text", "store": true, "analyzer": "ik_max_word", "search_analyzer": "ik_smart" } } } } } } ``` 如果我强制把这个改成LONG,执行保存的时候,就会抛异常 ![图片说明](https://img-ask.csdn.net/upload/201906/28/1561688803_802718.png) 这是为什么呀,感觉好烦呀,虽然不影响我用,我也不会把ID设置成LONG,但是我搜遍了全网也没有找到有这类的问题,如果是官方就这么设计的,希望大家告诉我一下,顺便告诉我在哪看到的这么设计的,我的环境是 ``` <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <version>2.1.6.RELEASE</version> </dependency> ``` jdk是1.8 elasticsearch是6.2.4版本,我的强迫症都快犯了
spring-data-elasticsearch 一对多
现在有三个实体类 关系是一个产品有多个属性 一个属性有多个属性值 如下: 实体类EsProduct: ``` @Document(indexName = "product", type = "productInfo",shards = 2,replicas = 1,refreshInterval = "-1") public class EsProduct implements Serializable { private static final long serialVersionUID = 2372551074091780419L; @Id private Long id; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String productSn; private Long brandId; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String brandName; private Long productCategoryId; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String productName; private Long sale; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String subTitle; private BigDecimal price; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String keywords; private List<EsProductAttribute> attributeList; private EsProductCategory productCategorie; ``` 实体类EsProductAttribute: ``` public class EsProductAttribute implements Serializable { private static final long serialVersionUID = 4965902919813623705L; @Id private Long id; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String paProductAttributeName;//属性名称 private List<EsProductAttributeValue> attributeValues; ``` 实体类EsProductAttributeValue: ``` public class EsProductAttributeValue implements Serializable { private static final long serialVersionUID = 6713756365860464751L; private Long id; @Field(analyzer = "ik_max_word",type = FieldType.Text) private String pavProductAttributeValue; ``` 之前的搜索是这样的,可以成功搜索 控制层代码: ``` @ApiOperation(value = "简单搜索:根据关键字,品牌名称或者产品名称,产品编号,副标题搜索(字符串:Text类型最大拆分)") @RequestMapping(value = "/search/keyword", method = RequestMethod.GET) @ResponseBody public CommonResult<CommonPage<EsProduct>> searchKeyword(@RequestParam(required = false) String keyword, @RequestParam(required = false, defaultValue = "0") Integer pageNum, @RequestParam(required = false, defaultValue = "5") Integer pageSize) { Page<EsProduct> esProductPage = esProductService.searchKeyword(keyword, pageNum, pageSize); return CommonResult.success(CommonPage.restPage(esProductPage)); } ``` 业务实现层代码: ``` @Autowired private EsProductRepository productRepository; @Override public Page<EsProduct> searchKeyword(String keyword, Integer pageNum, Integer pageSize) { Pageable pageable = PageRequest.of(pageNum, pageSize); return productRepository.findByKeywordsOrProductNameOrBrandNameOrProductSnOrSubTitle(keyword,keyword,keyword,keyword,keyword,pageable); } ``` EsProductRepository接口 ``` public interface EsProductRepository extends ElasticsearchRepository<EsProduct, Long> { /** * 根据关键字,产品名称,品牌名称,产品编号搜索 * @param keywords * @param productName * @param brandName * @param page * @return */ Page<EsProduct> findByKeywordsOrProductNameOrBrandNameOrProductSnOrSubTitle(String keywords,String productName,String brandName,String productSn,String subTitle,Pageable page); } ``` 都可以成功搜索 但是在进行属性和属性值搜索的时候告诉我说在EsProduct中找不到paProductAttributeName,我一想有道理,然后改变策略 单独写了一个接口测试 控制层 ``` @ApiOperation(value = "属性和属性值搜索、筛选、排序") @ApiImplicitParam(name = "sort", value = "排序字段:0->按相关度;1->按销量;2->价格从低到高;3->价格从高到低", defaultValue = "0", allowableValues = "0,1,2,3", paramType = "query", dataType = "integer") @RequestMapping(value = "/search", method = RequestMethod.GET) @ResponseBody public CommonResult<CommonPage<EsProduct>> search(@RequestParam(required = false) String keyword, @RequestParam(required = false, defaultValue = "0") Integer pageNum, @RequestParam(required = false, defaultValue = "5") Integer pageSize, @RequestParam(required = false, defaultValue = "0") Integer sort) { Page<EsProduct> esProductPage = esProductService.search(keyword,pageNum, pageSize, sort); return CommonResult.success(CommonPage.restPage(esProductPage)); } ``` 业务实现层: ``` @Override public Page<EsProduct> search(String keyword,Integer pageNum, Integer pageSize,Integer sort) { Pageable pageable = PageRequest.of(pageNum, pageSize); //将连接条件和聚合函数等组合 NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder(); //分页 nativeSearchQueryBuilder.withPageable(pageable); //搜索 if (StringUtils.isEmpty(keyword)) { nativeSearchQueryBuilder.withQuery(QueryBuilders.matchAllQuery()); } else { List<FunctionScoreQueryBuilder.FilterFunctionBuilder> filterFunctionBuilders = new ArrayList<>(); //QueryBuilders:简单的静态工厂”导入静态”使用。主要作用是查询条件(关系),如区间\精确\多值等条件 //属性名称 filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("paProductAttributeName", keyword), ScoreFunctionBuilders.weightFactorFunction(2))); //属性值 filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("value", keyword), ScoreFunctionBuilders.weightFactorFunction(2))); //产品名称 // filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("productName",keyword), // ScoreFunctionBuilders.weightFactorFunction(2))); // //关键字 // filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("keywords", keyword), // ScoreFunctionBuilders.weightFactorFunction(2))); // //产品编号 // filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("productSn", keyword), // ScoreFunctionBuilders.weightFactorFunction(2))); FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()]; filterFunctionBuilders.toArray(builders); FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(builders) .scoreMode(FunctionScoreQuery.ScoreMode.SUM) .setMinScore(2); nativeSearchQueryBuilder.withQuery(functionScoreQueryBuilder); } // //排序 // if(sort==1){ // //按销量从高到低 // nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("sale").order(SortOrder.DESC)); // }else if(sort==2){ // //按价格从低到高 // nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("price").order(SortOrder.ASC)); // }else if(sort==3){ // //按价格从高到低 // nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("price").order(SortOrder.DESC)); // }else{ // //按相关度 // nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC)); // } nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC)); NativeSearchQuery searchQuery = nativeSearchQueryBuilder.build(); LOGGER.info("DSL:{}", searchQuery.getQuery().toString()); return productRepository.search(searchQuery); } ``` es中的数据是: ``` { "code": 200, "message": "操作成功", "data": { "pageNum": 0, "pageSize": 5, "totalPage": 4, "total": 17, "list": [ { "id": 40, "productSn": "C146179 ", "brandId": null, "brandName": "PSA(信昌电陶)", "productCategoryId": 54, "productName": "贴片电容/220nF(224)±10%250V编带", "sale": 1000, "subTitle": "贴片电容", "price": null, "keywords": "贴片电容/220nF(224) ±10% 250V 编带 ", "attributeList": [ { "id": 49, "paProductAttributeName": "容值", "attributeValues": [ { "id": 240, "pavProductAttributeValue": "0.1pf" }, { "id": 241, "pavProductAttributeValue": "0.2pf" }, { "id": 242, "pavProductAttributeValue": "0.25pf" }, { "id": 243, "pavProductAttributeValue": "0.3pf" }, { "id": 244, "pavProductAttributeValue": "0.4pf" } ] }, { "id": 51, "paProductAttributeName": "额定电压", "attributeValues": [ { "id": 290, "pavProductAttributeValue": "4v" }, { "id": 292, "pavProductAttributeValue": "10v" }, { "id": 296, "pavProductAttributeValue": "30v" } ] } ], "productCategorie": { "id": 54, "productCategoryName": "贴片电容" } }, { "id": 41, "productSn": "C394163 ", "brandId": null, "brandName": "PSA(信昌电陶)", "productCategoryId": 54, "productName": "贴片电容/10nF(103) ±10% 1KV", "sale": 1000, "subTitle": "贴片电容", "price": null, "keywords": "贴片电容/10nF(103) ±10% 1KV ", "attributeList": [ { "id": 49, "paProductAttributeName": "容值", "attributeValues": [ { "id": 245, "pavProductAttributeValue": "0.5pf" }, { "id": 246, "pavProductAttributeValue": "0.6pf" }, { "id": 247, "pavProductAttributeValue": "0.68pf" } ] }, { "id": 50, "paProductAttributeName": "精度", "attributeValues": [ { "id": 272, "pavProductAttributeValue": "+0.05pf" }, { "id": 273, "pavProductAttributeValue": "+0.1pf" }, { "id": 274, "pavProductAttributeValue": "+0.25pf" } ] }, { "id": 51, "paProductAttributeName": "额定电压", "attributeValues": [ { "id": 291, "pavProductAttributeValue": "6.3v" }, { "id": 293, "pavProductAttributeValue": "16v" }, { "id": 297, "pavProductAttributeValue": "35v" } ] } ], "productCategorie": { "id": 54, "productCategoryName": "贴片电容" } }, { "id": 44, "productSn": "C342641 ", "brandId": null, "brandName": "TDK", "productCategoryId": 54, "productName": "贴片电容/47nF(473) ±5% 100V 编带", "sale": 1000, "subTitle": "贴片电容", "price": null, "keywords": "贴片电容/47nF(473) ±5% 100V 编带 ", "attributeList": [ { "id": 49, "paProductAttributeName": "容值", "attributeValues": [ { "id": 254, "pavProductAttributeValue": "1.3pf" }, { "id": 255, "pavProductAttributeValue": "1.4pf" }, { "id": 256, "pavProductAttributeValue": "2pf" }, { "id": 257, "pavProductAttributeValue": "2.1pf" } ] }, { "id": 50, "paProductAttributeName": "精度", "attributeValues": [ { "id": 278, "pavProductAttributeValue": "+5%" } ] } ], "productCategorie": { "id": 54, "productCategoryName": "贴片电容" } }, { "id": 48, "productSn": "C11366 ", "brandId": null, "brandName": " AVX", "productCategoryId": 55, "productName": "钽电容/22uF(226) ±10% 10V", "sale": 1000, "subTitle": "钽电容", "price": null, "keywords": "钽电容/22uF(226) ±10% 10V ", "attributeList": [ { "id": 49, "paProductAttributeName": "容值", "attributeValues": [ { "id": 269, "pavProductAttributeValue": "0.1pf" }, { "id": 270, "pavProductAttributeValue": "0.2pf" } ] }, { "id": 50, "paProductAttributeName": "精度", "attributeValues": [ { "id": 271, "pavProductAttributeValue": "+0.02pf" }, { "id": 284, "pavProductAttributeValue": "-20%,+80%" } ] } ], "productCategorie": { "id": 55, "productCategoryName": "钽电容" } }, { "id": 52, "productSn": "C391913 ", "brandId": null, "brandName": "SAMYOUNG(韩国三莹)", "productCategoryId": 56, "productName": "贴片电解电容/10uF ±20% 50V", "sale": 1000, "subTitle": "贴片电解电容", "price": null, "keywords": "贴片电解电容/10uF ±20% 50V ", "attributeList": [], "productCategorie": { "id": 56, "productCategoryName": "贴片电解电容" } } ] } } ``` 然后搜索了半天一点反应也没有,也没有头绪,求助大神指点
使用elasticsearchTemplate检索报错Field [location] is not of type [geo_shape] but of type [geo_point]
实体: ``` @Document(indexName = "elastic_search_project",type = "person",shards = 1,replicas = 0, refreshInterval = "-1") @Getter @Setter public class GeoEntity { @Id private String id; private String name; private String content; @GeoPointField private GeoPoint location; public GeoEntity() { } } ``` # 使用Geo_PONIT多边形检索可以成功(因为实体中有GEO_POINT映射);但现在要使用圆形检索,需要使用GEO_SHAPE,实体中应该怎么映射? ``` @RequestMapping("/searchByShape") public Page<GeoEntity> searchByShape( double lat, double lon, double distance, Pageable pageable) { //构造查询条件 NativeSearchQueryBuilder nativeSearchQueryBuilder = null; try { nativeSearchQueryBuilder = new NativeSearchQueryBuilder() .withFilter(QueryBuilders.geoShapeQuery("location", ShapeBuilders.newCircleBuilder().radius(distance, DistanceUnit.KILOMETERS).center(lon,lat))) .withPageable(pageable); } catch (IOException e) { e.printStackTrace(); } Page<GeoEntity> page = elasticsearchTemplate.queryForPage( nativeSearchQueryBuilder.build(), GeoEntity.class); return page; } ``` # 错误信息 ``` org.elasticsearch.index.query.QueryShardException: Field [location] is not of type [geo_shape] but of type [geo_point] at org.elasticsearch.index.query.GeoShapeQueryBuilder.doToQuery(GeoShapeQueryBuilder.java:381) at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:104) at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$2(QueryShardContext.java:305) at org.elasticsearch.index.query.QueryShardContext$$Lambda$3084/1953286000.apply(Unknown Source) at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:317) at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:304) at org.elasticsearch.search.SearchService.parseSource(SearchService.java:769) at org.elasticsearch.search.SearchService.createContext(SearchService.java:616) at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:592) at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:304) at org.elasticsearch.search.SearchService.access$000(SearchService.java:121) at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:290) at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:286) at org.elasticsearch.search.SearchService$4.doRun(SearchService.java:1082) at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:723) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) ```
使用spring-data API 搜索es 集合类型数据
使用spring-data-es API进行 es 搜索 建的索引中 有个 字段 List<String> 类型。 如何搜索这种类型。 尝试了下面这种方式,没法搜索成功。 ``` boolQueryBuilder.must(QueryBuilders.termQuery("consignCodeList",invoiceQueryPageB.getInvoiceConsignCode())); ``` 请求下,有遇到类似问题的大神吗,指点一下。
求助sprinboot整合 elasticsearch-rest-high-level-client-5.6.4报错
以下是报错信息: Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientConfigurations$RestHighLevelClientConfiguration.elasticsearchRestHighLevelClient(RestClientConfigurations.java:75) The following method did not exist: org.elasticsearch.client.RestHighLevelClient.<init>(Lorg/elasticsearch/client/RestClientBuilder;)V The method's class, org.elasticsearch.client.RestHighLevelClient, is available from the following locations: jar:file:/Users/jianxiaowen/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/5.6.4/elasticsearch-rest-high-level-client-5.6.4.jar!/org/elasticsearch/client/RestHighLevelClient.class It was loaded from the following location: file:/Users/jianxiaowen/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/5.6.4/elasticsearch-rest-high-level-client-5.6.4.jar Action: Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RestHighLevelClient 以下是pom文件,是springboot版本和这个es不兼容吗,原来用的es6.x是可以的,换成5.x就不行了,但是公司环境就要求5.x: ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.xxx</groupId> <artifactId>repservice</artifactId> <version>1.0</version> <modules> <module>kg-business</module> </modules> <packaging>pom</packaging> <name>repservice</name> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.7.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <elasticsearch.version>5.6.4</elasticsearch.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>com.x x x.datanlp</groupId> <artifactId>graph-db-sdk</artifactId> <version>1.1-SNAPSHOT</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.13</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>2.1.10.RELEASE</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.restdocs</groupId> <artifactId>spring-restdocs-mockmvc</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter-test</artifactId> <version>2.1.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> <version>5.2.4</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.3</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.12</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.10</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpmime</artifactId> <version>4.5.10</version> </dependency> <dependency> <groupId>io.reactivex.rxjava2</groupId> <artifactId>rxjava</artifactId> <version>2.2.9</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>3.6</version> </dependency> <!-- 引入 redis 依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.solr/solr-solrj --> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>8.2.0</version> </dependency> <!-- 解压rar --> <dependency> <groupId>com.github.junrar</groupId> <artifactId>junrar</artifactId> <version>4.0.0</version> </dependency> <!-- 解压zip --> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.10.7</version> </dependency> <!--结果验证--> <dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> <version>2.4.0</version> </dependency> <!-- 临时--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.51</version> </dependency> <dependency> <groupId>com.arangodb</groupId> <artifactId>arangodb-java-driver</artifactId> <version>5.0.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-web --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-web</artifactId> <version>2.7</version> </dependency> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>5.6.4</version> </dependency> <!-- Java Low Level REST Client --> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-client</artifactId> <version>5.6.4</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>5.6.4</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> ```
elasticsearch network_host 参数填写机器外网地址,启动失败
elasticsearch network_host 参数填写机器外网地址,启动失败 Caused by: java.net.BindException: Cannot assign requested address
elasticsearch连接出错
1、错误截图 ``` 2019-12-06 10:39:43.846 ERROR 2824 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{OAnbfg_bSjCat5ebeRNMTg}{127.0.0.1}{127.0.0.1:9300}]]] with root cause org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{OAnbfg_bSjCat5ebeRNMTg}{127.0.0.1}{127.0.0.1:9300}] at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54) ~[elasticsearch-5.6.1.jar:5.6.1] at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:62) ~[elasticsearch-5.6.1.jar:5.6.1] at com.imooc.service.search.SearchServiceImpl.aggregateDistrictHouse(SearchServiceImpl.java:460) ~[classes/:na] at com.imooc.web.controller.house.HouseController.show(HouseController.java:207) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.20.jar:8.5.20] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.11.RELEASE.jar:4.3.11.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.20.jar:8.5.20] ``` ![图片说明](https://img-ask.csdn.net/upload/201912/06/1575600402_940718.jpg) 2、elasticsearch配置信息 ``` cluster.name: elasticsearch # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: master node.master: true node.data: true # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # #path.data: /path/to/data # # Path to log files: # #path.logs: /path/to/logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 127.0.0.1 # # Set a custom port for HTTP: # #http.port: 9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # #discovery.zen.ping.unicast.hosts: ["host1", "host2"] # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # #discovery.zen.minimum_master_nodes: 3 # # For more information, consult the zen discovery module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true #bootstrap.system_call_filter: false http.cors.enabled: true http.cors.allow-origin: "*" ``` 3、spring项目配置信息 ``` package com.imooc.config; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.transport.client.PreBuiltTransportClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.net.InetAddress; import java.net.UnknownHostException; @Configuration public class ElasticSearchConfig { @Value("${elasticsearch.host}") private String esHost; @Value("${elasticsearch.port}") private int esPort; @Value("${elasticsearch.cluster.name}") private String esName; @Bean public TransportClient esClient() throws UnknownHostException { Settings settings = Settings.builder() .put("cluster.name", this.esName) // .put("cluster.name", "elasticsearch") .put("client.transport.sniff", true) .build(); InetSocketTransportAddress master = new InetSocketTransportAddress( InetAddress.getByName(esHost), esPort // InetAddress.getByName("192.168.100.106"), 8999 ); TransportClient client = new PreBuiltTransportClient(settings) .addTransportAddress(master); return client; } } ``` 4、application.propertires ``` elasticsearch.cluster.name=xunwu elasticsearch.host=127.0.0.1 elasticsearch.port=9300 ```
spring-boot与elasticsearch整合时如何定义内嵌对象的分词策略
@Document(indexName = "logmodel", type = "logs", shards = 4, replicas = 1,indexStoreType="fs", refreshInterval = "-1") public class LogES { @Id private String id; private String itcode; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String ip; private String ad_type; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String telephone; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String mobile; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String email; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String firstname; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String firstnameen; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String boss; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String position; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String organization; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String country; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String cityname; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String givenname; private String employeeNumber; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String employeetype; private boolean ismanager; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String bossname; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String bigboss; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String bigbossname; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String enterprise; @JsonFormat (shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd'T'hh:mm:ss.SSS'Z'") private Date dt; private String dev_platform; private String app_version; private String dev_version; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String dev_info; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String dev_imei; @Field(type = FieldType.String,index = FieldIndex.not_analyzed) private String func; @Field( type = FieldType.Auto) private Object content; private CochatResponseEntity cochatResponseEntity; 比如怎么设置content对象内部字段的分词策略,如:@Field(type = FieldType.String,index = FieldIndex.not_analyzed)
springboot整合elasticsearch提示org.elasticsearch.transport.NodeDisconnectedException
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <version>2.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-elasticsearch</artifactId> <version>2.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>org.elasticsearch.plugin</groupId> <artifactId>transport-netty4-client</artifactId> <version>6.4.0</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>transport</artifactId> <version>6.4.0</version> </dependency> application.yml 配置如下: spring: data: elasticsearch: cluster-nodes: 192.168.100.21:9300,192.168.100.22:9300,192.168.100.23:9300 cluster-name: wt repositories: enabled: true springboot版本1.5.8,linux安装ES版本是6.4.0,上面是工程里引入的jar,ES在浏览器能访问,且有数据,但是项目启动就连接不上 NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{192.168.100.21}{192.168.100.21:9300}, {#transport#-2}{192.168.100.22}{192.168.100.22:9300}, {#transport#-3}{192.168.100.23}{192.168.100.23:9300}] ] at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290) at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207) at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55) at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
java连接elasticsearch抛异常None of the configured nodes are available
阿里云上docker方式部署了单节点的6.5.3版本的es,elasticsearch.yml配置如下: ``` cluster.name: "docker-cluster" node.name: node-test network.bind_host: 0.0.0.0 network.publish_host: 58.87.73.232 discovery.zen.ping.unicast.hosts: ["58.87.73.232:9300"] discovery.zen.minimum_master_nodes: 1 http.cors.enabled: true http.cors.allow-origin: "*" ``` 通过springboot2.1.1项目集成spring-boot-starter-data-elasticsearch application.properties配置如下: ``` spring.data.elasticsearch.cluster-name=docker-cluster spring.data.elasticsearch.cluster-nodes=58.87.73.232:9300 ``` 启动项目的测试用例抛异常**NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{rLnGNbz3QFaEToPtiuFTgQ}{58.87.73.232}{58.87.73.232:9300}]] ** 请问什么原因? 附节点状态截图: ![图片说明](https://img-ask.csdn.net/upload/201909/10/1568100643_439007.png)
Elasticsearch 6.0 curl 导入 Kibana 示例数据出错,求救
按照官网的示例 导入数据 三个json格式数据文件 shakespeare.json, accounts.json, logs.jsonl ``` curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl ``` ![图片说明](https://img-ask.csdn.net/upload/201711/25/1511599223_96934.png) 网上搜索没有找到解决方式 "error" : "Content-Type header [application/x-www-form-urlencoded] is not supported", "status" : 406
linux中用 elasticsearch 下载的 x-pack 没有 setup-passwords
linux中用 elasticsearch 下载的 x-pack 没有 setup-passwords
Elasticsearch使用elasticsearch-river-jdbc同步
我确定连接是无问题,表里数据也有,而且我也insert了很多条数据 同步:curl -XPOST 'localhost:9200/_river/my_geo_river/_meta' -d ' > { > "type" : "jdbc", > "jdbc" : { > "url" : "jdbc:mysql://localhost:3306/profile", > "user" : "root", > "password" : "root", > "locale" : "en_US", > "sql" : [ > { > "statement" : "select \"name\" as _index, \"login_name\" as _type, id as _id from user" > } > ], > "index" :"myjdbc", > "type" : "mytype" > } > } > ' 但是得到结果:curl -XGET 'localhost:9200/myjdbc/_search?pretty' { "took" : 3, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "failed" : 0 }, "hits" : { "total" : 0, "max_score" : null, "hits" : [ ] } }
ElasticSearch 6.3.2版本整合springBoot 报错 java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50)
在服务器上搭建了一个单机的ElasticSearch 版本6.3.2,因为本地访问服务器的9200端口访问不到(network.host:0.0.0.0启动报错),所以用nginx做了代理9002端口对应9200,9001端口对应9300,直接访问访问成功如下:![图片说明](https://img-ask.csdn.net/upload/202002/08/1581096007_348190.jpg)![图片说明](https://img-ask.csdn.net/upload/202002/08/1581096016_248026.png) 然后我用写了个Demo但是一直报错 java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50); 配置文件如下: ![图片说明](https://img-ask.csdn.net/upload/202002/08/1581096398_340973.jpg) ![图片说明](https://img-ask.csdn.net/upload/202002/08/1581096609_898535.jpg) 错误日志和pom.xml文件如下: ``` exception caught on transport layer [NettyTcpChannel{localAddress=/192.168.1.103:61678, remoteAddress=/xxx.xxx.xxx.xxx:9001}], closing connection io.netty.handler.codec.DecoderException: java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:472) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241) [netty-handler-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:648) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:548) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:502) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.31.Final.jar:4.1.31.Final] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191] Caused by: java.io.StreamCorruptedException: invalid internal transport message format, got (48,54,54,50) at org.elasticsearch.transport.TcpTransport.validateMessageHeader(TcpTransport.java:1315) ~[elasticsearch-6.3.2.jar:6.4.3] at org.elasticsearch.transport.netty4.Netty4SizeHeaderFrameDecoder.decode(Netty4SizeHeaderFrameDecoder.java:36) ~[transport-netty4-client-6.4.3.jar:6.4.3] at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final] at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441) ~[netty-codec-4.1.31.Final.jar:4.1.31.Final] ... 19 common frames omitted ``` pom.xml文件如下 ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com</groupId> <artifactId>elasticsearchtest</artifactId> <version>0.0.1-SNAPSHOT</version> <name>elasticsearchtest</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>6.3.2</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>transport</artifactId> <version>6.3.2</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>6.3.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.10</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> ``` 请大神帮忙看看,谢谢啦!
es 批量插入MySQL数据 数据类型为timestamp 怎么设置es日期时间类型
\"type\":\"illegal_argument_exception\",\"reason\":\"failed to parse date field [-62170012800] with format [date_time]\ 上面的是es(7.x)设置为date_time 类型时报的错误 MySQL中的数据是2019-08-30 12:20:24 格式如下: `receipt_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
Centos7运行elasticsearch-6.5.4报错
# Centos7运行elasticsearch-6.5.4报错 ![图片说明](https://img-ask.csdn.net/upload/202001/09/1578550525_662554.jpg) ,bootstrap checks failed [1]: Java version [1.8.0_222-ea] is an early-access build, only use release builds 搞不定啊啊啊啊
house索引信息文档丢失异常[[data_doc][10777]:文档丢失]
服务器里面修改es索引文档的时候 出现 ``` 04-Dec-2019 09:53:04.318 INFO [pool-2-thread-1] com.chuangting.house.service.impl.HouseServiceImpl.get 读取房源信息完成 2019-12-04 09:53:04.318 [pool-2-thread-1] INFO com.chuangting.house.service.impl.HouseServiceImpl - 读取房源信息完成 [house_index_info/jyw7DuMSQLmbIQfoSRaDjw][[house_index_info][1]] DocumentMissingException[[data_doc][10777]: document missing] ``` 哪位大佬知道是什么情况造成的
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小人工智障。 思路可以运用在不同地方,主要介绍的是思路。
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
阿里面试官问我:如何设计秒杀系统?我的回答让他比起大拇指
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图和个人联系方式,欢迎Star和指教 前言 Redis在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在Redis的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了...
C语言魔塔游戏
很早就很想写这个,今天终于写完了。 游戏截图: 编译环境: VS2017 游戏需要一些图片,如果有想要的或者对游戏有什么看法的可以加我的QQ 2985486630 讨论,如果暂时没有回应,可以在博客下方留言,到时候我会看到。 下面我来介绍一下游戏的主要功能和实现方式 首先是玩家的定义,使用结构体,这个名字是可以自己改变的 struct gamerole { char n...
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
Android性能优化(4):UI渲染机制以及优化
文章目录1. 渲染机制分析1.1 渲染机制1.2 卡顿现象1.3 内存抖动2. 渲染优化方式2.1 过度绘制优化2.1.1 Show GPU overdraw2.1.2 Profile GPU Rendering2.2 卡顿优化2.2.1 SysTrace2.2.2 TraceView 在从Android 6.0源码的角度剖析View的绘制原理一文中,我们了解到View的绘制流程有三个步骤,即m...
微服务中的Kafka与Micronaut
今天,我们将通过Apache Kafka主题构建一些彼此异步通信的微服务。我们使用Micronaut框架,它为与Kafka集成提供专门的库。让我们简要介绍一下示例系统的体系结构。我们有四个微型服务:订单服务,行程服务,司机服务和乘客服务。这些应用程序的实现非常简单。它们都有内存存储,并连接到同一个Kafka实例。 我们系统的主要目标是为客户安排行程。订单服务应用程序还充当网关。它接收来自客户的请求...
致 Python 初学者们!
作者| 许向武 责编 | 屠敏 出品 | CSDN 博客 前言 在 Python 进阶的过程中,相信很多同学应该大致上学习了很多 Python 的基础知识,也正在努力成长。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 Python 这门编程语言,从2009年开始单一使用 Python 应对所有的开发工作,直至今...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观...
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外...
字节跳动面试官这样问消息队列:分布式事务、重复消费、顺序消费,我整理了一下
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip installselenium -ihttps://pypi.tuna.tsinghua.edu.cn/simple/ ...
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca...
SpringBoot2.x系列教程(三十六)SpringBoot之Tomcat配置
Spring Boot默认内嵌的Tomcat为Servlet容器,关于Tomcat的所有属性都在ServerProperties配置类中。同时,也可以实现一些接口来自定义内嵌Servlet容器和内嵌Tomcat等的配置。 关于此配置,网络上有大量的资料,但都是基于SpringBoot1.5.x版本,并不适合当前最新版本。本文将带大家了解一下最新版本的使用。 ServerProperties的部分源...
Python绘图,圣诞树,花,爱心 | Turtle篇
每周每日,分享Python实战代码,入门资料,进阶资料,基础语法,爬虫,数据分析,web网站,机器学习,深度学习等等。 公众号回复【进群】沟通交流吧,QQ扫码进群学习吧 微信群 QQ群 1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle()...
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东...
破14亿,Python分析我国存在哪些人口危机!
一、背景 二、爬取数据 三、数据分析 1、总人口 2、男女人口比例 3、人口城镇化 4、人口增长率 5、人口老化(抚养比) 6、各省人口 7、世界人口 四、遇到的问题 遇到的问题 1、数据分页,需要获取从1949-2018年数据,观察到有近20年参数:LAST20,由此推测获取近70年的参数可设置为:LAST70 2、2019年数据没有放上去,可以手动添加上去 3、将数据进行 行列转换 4、列名...
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o...
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ...... ...
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。 再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。 下文是原回答,希望能对你能有所启发。 如果我说,这个世界上人真的分三六九等,...
2020年全新Java学习路线图,含配套视频,学完即为中级Java程序员!!
新的一年来临,突如其来的疫情打破了平静的生活! 在家的你是否很无聊,如果无聊就来学习吧! 世上只有一种投资只赚不赔,那就是学习!!! 传智播客于2020年升级了Java学习线路图,硬核升级,免费放送! 学完你就是中级程序员,能更快一步找到工作! 一、Java基础 JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。 在Java基础板块中有6个子模块的学...
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合...
爬取薅羊毛网站百度云资源
这是疫情期间无聊做的爬虫, 去获取暂时用不上的教程 import threading import time import pandas as pd import requests import re from threading import Thread, Lock # import urllib.request as request # req=urllib.request.Requ...
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名...
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计...
HTML5适合的情人节礼物有纪念日期功能
前言 利用HTML5,css,js实现爱心树 以及 纪念日期的功能 网页有播放音乐功能 以及打字倾诉感情的画面,非常适合情人节送给女朋友 具体的HTML代码 具体只要修改代码里面的男某某和女某某 文字段也可自行修改,还有代码下半部分的JS代码需要修改一下起始日期 注意月份为0~11月 也就是月份需要减一。 当然只有一部分HTML和JS代码不够运行的,文章最下面还附加了完整代码的下载地址 &lt;!...
相关热词 c#导入fbx c#中屏蔽键盘某个键 c#正态概率密度 c#和数据库登陆界面设计 c# 高斯消去法 c# codedom c#读取cad文件文本 c# 控制全局鼠标移动 c# temp 目录 bytes初始化 c#
立即提问