Elasticsearch 7.6.2 版本 @Document 注解 shards配置不生效
7.6.2版本中@Document注解shards属性默认为1,配置为5后,创建出来的索引,仍然只有1个分片
@Document(indexName = "stu1", shards = 5) @Data @NoArgsConstructor @AllArgsConstructor public class Stu { @Id private Long stuId; @Field(store = true) private String stuName; @Field(store = true) private Integer age; } @RunWith(SpringRunner.class) @SpringBootTest(classes = ESApplication.class) public class ESTest { @Autowired private ElasticsearchRestTemplate elasticsearchRestTemplate; @Test public void createStuIndex() { Stu stu = new Stu(1001L, "leslie", 18); IndexCoordinates indexCoordinates = elasticsearchRestTemplate.getIndexCoordinatesFor(stu.getClass()); IndexQuery indexQuery = new IndexQueryBuilder().withObject(stu).build(); // elasticsearchRestTemplate.save(stu); elasticsearchRestTemplate.index(indexQuery, indexCoordinates); } }
老师请问,创建出来的索引的 shards 参数可以通过在 @Document 注解中配置实现么。还是只支持默认的 shards。
43
收起
正在回答
1回答
嗯对,这个shard的确不生效,不用管。索引前期取消创建好就行。另外版本一定要和springboot的统一啊
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星