在ES中,可以使用Java Low Level REST Client来创建索引和执行查询操作。本文将介绍如何使用Java Low Level REST Client来创建索引和执行查询,并给出相应的代码示例。 首先,我们需要在Java项目中引入Elasticsearch的Java Low Level REST Client的依赖。可以在项目的pom.xml文件中添加以下依赖: <dependency><groupId>org....
事件类 public class Event { private Long eventId; private Long catalogId; private Long orgId; private String orgName; private String catalogName; private String name; private String eventStatus;... }objectmapper 用于将事件对象转换为 json 字符串。这是插入文档的代码public String createEventDocument(...
@Before public void prepare() { // 创建Client连接对象 //String[] ips = {"127.0.0.1:9200"}; String[] ips = {"47.104.193.89:9200", "47.104.180.62:9200"}; HttpHost[] httpHosts = new HttpHost[ips.length]; for (int i = 0; i < ips.length; i++) { httpHosts[i] = HttpHost.c...