public JestClient getJestCline(){
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder("http://127.0.0.1:9200")
.multiThreaded(true)
.build());
return factory.getObject();
}
@Test
void contextLoads() {
JestClient jestClient = getJestCline();
Article article=new Article();
article.setAuthor("zhangsan");
article.setTitle("好消息");
article.setContext("hello,word");
article.setId(1);
//构建一个索引功能,index,索引位置,type索引类型,id,已经有了不写了,build构建开始构建
Index index=new Index.Builder(article).index("atguigu").type("news").build();
try {
//执行这个索引
jestClient.execute(index);
} catch (IOException e) {
e.printStackTrace();
}
}
JestClient爆红,不支持自动注入JestClient解决式例
最新推荐文章于 2022-10-25 13:53:26 发布