spring-data-elasticsearch es6.7.2 save child throw Exception :routing is missing for join field

  Kiến thức lập trình

pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

springboot version 2.1.6.RELEASE

elasticsearch 6.7.2

{ "type": "join", "relations": {  "article": "comment" } }

when I save childEntity throw java.lang.IllegalArgumentException: [routing] is missing for join field [info]

My entity:

parent:

public class Article implements Serializable {
    @Id
    private String id;
    private String title;
    private String author;
    private String content;
    private Date created;
    private Map<String,Object> comments;
}

child:

public class Comment implements Serializable {
    @Id
    private String id;
    private String name;
    private String content; 
    private Date created;
    @Field(includeInParent = true)
    @Mapping(mappingPath = "/mapping/mapping.json")
    private Map<String, Object> comments;
}

when I user repository save child,throw Excption ,I don’t konw how to do config routing perporties for my bean.

at org.elasticsearch.join.mapper.ParentJoinFieldMapper.parse(ParentJoinFieldMapper.java:426)
at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:488)
at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:505)
at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:395)
at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:384)
at org.elasticsearch.index.mapper.DocumentParser.internalParseDocument(DocumentParser.java:96)
at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:69)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:281)
at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:799)
at org.elasticsearch.index.shard.IndexShard.applyIndexOperation(IndexShard.java:775)
at org.elasticsearch.index.shard.IndexShard.applyIndexOperationOnPrimary(IndexShard.java:744)
at org.elasticsearch.action.bulk.TransportShardBulkAction.lambda$executeIndexRequestOnPrimary$3(TransportShardBulkAction.java:454)
at org.elasticsearch.action.bulk.TransportShardBulkAction.executeOnPrimaryWhileHandlingMappingUpdates(TransportShardBulkAction.java:477)
at org.elasticsearch.action.bulk.TransportShardBulkAction.executeIndexRequestOnPrimary(TransportShardBulkAction.java:452)
at org.elasticsearch.action.bulk.TransportShardBulkAction.executeBulkItemRequest(TransportShardBulkAction.java:216)
at org.elasticsearch.action.bulk.TransportShardBulkAction.performOnPrimary(TransportShardBulkAction.java:159)
at org.elasticsearch.action.bulk.TransportShardBulkAction.performOnPrimary(TransportShardBulkAction.java:151)
at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:139)
at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:79)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryShardReference.perform(TransportReplicationAction.java:1050)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryShardReference.perform(TransportReplicationAction.java:1028)
at org.elasticsearch.action.support.replication.ReplicationOperation.execute(ReplicationOperation.java:104)
at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncPrimaryAction.runWithPrimaryShardReference(TransportReplicationAction.java:424)
at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncPrimaryAction.lambda$doRun$0(TransportReplicationAction.java:370)
at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:61)
at org.elasticsearch.index.shard.IndexShardOperationPermits.acquire(IndexShardOperationPermits.java:273)
at org.elasticsearch.index.shard.IndexShardOperationPermits.acquire(IndexShardOperationPermits.java:240)
at org.elasticsearch.index.shard.IndexShard.acquirePrimaryOperationPermit(IndexShard.java:2561)
at org.elasticsearch.action.support.replication.TransportReplicationAction.acquirePrimaryOperationPermit(TransportReplicationAction.java:987)
at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncPrimaryAction.doRun(TransportReplicationAction.java:369)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:324)
at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:311)
at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$ProfileSecuredRequestHandler$1.doRun(SecurityServerTransportInterceptor.java:250)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor$ProfileSecuredRequestHandler.messageReceived(SecurityServerTransportInterceptor.java:308)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66)
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:692)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

2

LEAVE A COMMENT