提问:布和纸怕什么?

Springboot 集成elasticsearch 创建内嵌对象报错

Elasticsearch | 作者 wy993322 | 发布于2018年05月23日 | 阅读数:9322


@Document(indexName="china",type="province")
public class China  implements Serializable{
private static final long serialVersionUID = 1L;
@Id
private String id;
@Field(type=FieldType.text)
private String provinceNmae;

@Field(type=FieldType.Nested)
private List<City> listCity;//市

get;set;
}
 
@Component
public interface IChinaRepository extends ElasticsearchRepository<China, String> {}
 

@RestController
public class ChinaController {
@Autowired
private IChinaRepository repository;

@GetMapping("cgetf")
public Iterable<China> getChina(){
List<String> ids=new ArrayList<>();
ids.add("p1");
ids.add("p2");
ids.add("p3");
Iterable<China> list = this.repository.findAllById(ids);
return list;
}
}
启动springboot 报如下错误:
Caused by: java.lang.IllegalArgumentException: object mapping [listCity] can't be changed from non-nested to nested
已邀请:

wy993322 - 90

赞同来自:

提前建立好索引切片就可以 了

要回复问题请先登录注册