spring data es指定索引配置

在domain上指定settings

@Document(indexName = "myindex", type = "mylog", shards = 1, replicas = 1)
@Setting(settingPath = "elasticsearch/settings.json")
public class MyLog {
  //...
}

在resources文件夾下創建指定的配置

src/main/resources/elasticsearch/settings.jsonjava

{
  "index": {
    "action.write_consistency" : "all"
  }
}

測試

@Test
    public void reCreateIndex() {
        elasticsearchTemplate.deleteIndex(MyLog.class);
        elasticsearchTemplate.createIndex(MyLog.class);
    }

查看git

curl -XGET 192.168.99.100:9200/myindex/_settings

參考

相關文章
相關標籤/搜索