使用nested类型启动报错
rstyro opened this issue · comments
easy-es版本
- 使用目前最新版本:
2.0.0-beta7
- springboot pom如下:
<?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.7.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>top.lrshuai</groupId>
<artifactId>demo</artifactId>
<version>1.0.0</version>
<name>demo</name>
<description>demo</description>
<properties>
<java.version>1.8</java.version>
<!-- 统一es版本 -->
<elasticsearch.version>7.14.0</elasticsearch.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- es -->
<dependency>
<groupId>org.dromara.easy-es</groupId>
<artifactId>easy-es-boot-starter</artifactId>
<version>2.0.0-beta7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
- 索引entity如下:
@Data
@Accessors(chain = true)
@Settings(shardsNum = 3, replicasNum = 0)
@IndexName(value = "test", keepGlobalPrefix = true)
public class TestIndex {
@IndexId(type = IdType.CUSTOMIZE)
private String id;
// 作者简称
private List<String> au;
@HighLight(mappingField = "highlight")
@IndexField(fieldType = FieldType.NESTED, analyzer = Analyzer.IK_MAX_WORD)
private List<AuthorInfoVo> au_info;
}
- 使用的easy-es配置如下:
easy-es:
enable: true
address: localhost:9200
# schema: https
# username: elastic
# password: WG7WVmuNMtM4GwNYkyWH
keep-alive-millis: 18000
global-config:
i-kun-mode: true
process-index-mode: smoothly
async-process-index-blocking: true
print-dsl: true
db-config:
map-underscore-to-camel-case: true
id-type: customize
field-strategy: IGNORED
refresh-policy: immediate
enable-track-total-hits: true
- 启动报错如下:
2024-04-03 15:56:02.917 INFO 19400 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2024-04-03 15:56:02.925 INFO 19400 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2024-04-03 15:56:02.925 INFO 19400 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2024-04-03 15:56:03.021 INFO 19400 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2024-04-03 15:56:03.021 INFO 19400 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 801 ms
2024-04-03 15:56:03.408 INFO 19400 --- [ main] easy-es : ===> Smoothly process index mode activated
2024-04-03 15:56:03.610 INFO 19400 --- [onPool-worker-1] easy-es : ===> Index not exists, automatically creating index by easy-es...
java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "java.util.Collection.toArray()" because "c" is null
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1770)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Collection.toArray()" because "c" is null
at java.base/java.util.ArrayList.addAll(ArrayList.java:670)
at org.dromara.easyes.core.toolkit.IndexUtils.initIndexParam(IndexUtils.java:614)
at org.dromara.easyes.core.toolkit.IndexUtils.lambda$initInfo$22(IndexUtils.java:487)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.dromara.easyes.core.toolkit.IndexUtils.initInfo(IndexUtils.java:429)
at org.dromara.easyes.core.toolkit.IndexUtils.initMapping(IndexUtils.java:403)
at org.dromara.easyes.core.toolkit.IndexUtils.createIndex(IndexUtils.java:143)
at org.dromara.easyes.starter.service.impl.AutoProcessIndexSmoothlyServiceImpl.doCreateIndex(AutoProcessIndexSmoothlyServiceImpl.java:133)
at org.dromara.easyes.starter.service.impl.AutoProcessIndexSmoothlyServiceImpl.process(AutoProcessIndexSmoothlyServiceImpl.java:54)
at org.dromara.easyes.core.toolkit.IndexUtils.lambda$supplyAsync$34(IndexUtils.java:838)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1768)
... 8 more
2024-04-03 15:56:05.885 ERROR 19400 --- [onPool-worker-1] easy-es : process index exception:,java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "java.util.Collection.toArray()" because "c" is null
2024-04-03 15:56:05.885 WARN 19400 --- [onPool-worker-1] easy-es : ===> Unfortunately, auto process index by Easy-Es failed, please check your configuration
2024-04-03 15:56:06.148 INFO 19400 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2024-04-03 15:56:06.157 INFO 19400 --- [ main] top.lrshuai.ssedemo.SseDemoApplication : Started SseDemoApplication in 4.386 seconds (JVM running for 5.035)
- 虽然也能用,但是看到报错有点不爽
- 我不确定是不是
nested
类型的需要额外配置,文档中没有nested类型相关的 - 希望各位大佬,有空看一下
懂了,有个nestedClass属性