目录
TransportClient
TransportClient是ES原生自带的java api方式,不过ES可能计划在8.0版本后移除,使用TransportClient方便之处就是无需考虑springboot的版本等其他兼容问题。
引入TransportClient依赖
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
</dependency>
<!--<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>-->
创建索引
/** 创建索引
* @throws Exception
*/
@Test
public void creatIndex() throws Exception{
// 创建Client连接对象
Settings settings = Settings.builder().put("clust