Как создать в elasticsearch несколько типов через Spring Data?

Как я понимаю, индекс в еластике — это наподобие имени базы данных, а тип это таблица, но когда создаю сущности в java то такая ошибка:

Rejecting mapping update to [xxx] as the final mapping would have more than 1 type: [aaa, bbb]

Если поменять имя индекса, то все работает, что может быть и какое есть решение?

Вот пример кода:

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "xxx", type = "aaa")
public class Temp1 {

    @Id
    private String id;

    private String name;

    private Long cost;
}
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "xxx", type = "bbb")
public class Temp2 {

    @Id
    private Long id;

    private Boolean status;

    private Integer age;
}
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

public interface Temp1Repo extends ElasticsearchRepository<Temp1, String> {
}
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

public interface Temp2Repo extends ElasticsearchRepository<Temp2, String> {
}
org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'temp1Repo': 
Invocation of init method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]:
 Constructor threw exception; nested exception is java.lang.IllegalArgumentException:
 Rejecting mapping update to [xxx] as the final mapping would have more than 1 type: [aaa, bbb]
👍ПодобаєтьсяСподобалось0
До обраногоВ обраному0
LinkedIn
Дозволені теги: blockquote, a, pre, code, ul, ol, li, b, i, del.
Ctrl + Enter
Дозволені теги: blockquote, a, pre, code, ul, ol, li, b, i, del.
Ctrl + Enter

Підписатись на коментарі