第 22 章 Elasticsearch API
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>cn.netkiller</groupId> <artifactId>example</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>cn.netkiller</groupId> <artifactId>elastic</artifactId> <version>0.0.1-SNAPSHOT</version> <name>elastic</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>5.6.3</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>transport</artifactId> <version>5.6.3</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.8.2</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.8.2</version> </dependency> </dependencies> </project>
Settings settings = Settings.builder() .put("cluster.name", "elasticsearch") //集群名称 .put("client.transport.sniff", true) //自动嗅探 .put("discovery.type", "zen") .put("discovery.zen.minimum_master_nodes", 1) .put("discovery.zen.ping_timeout", "500ms") .put("discovery.initial_state_timeout", "500ms") .build(); Client client = new PreBuiltTransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), 9300));
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Alibaba Cloud E-MapReduce vs AWS EMR vs. Azure HDInsight
Big Data is among the biggest IT trends of the last five years. The idea behind this trend is that given a sufficiently large volume of data, it is possible to derive crucial business insights that could not be discovered through other methods. Of course, running Big Data analytics at scale requires a significant amount of processing power, and tools for parsing the da
- 下一篇
22.2. insert
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.Client; IndexResponse response = client.prepareIndex("information", "news", "1") .setSource("{ \"title\": \"ElasticSearch 5.5.2\"}") .get(); 使用 HashMap 插入 public void createData() { Map<String, Object> map = new HashMap<String, Object>(); map.put("name", "Neo Chen"); map.put("age", 30); map.put("book", new String[]{"Netkiller Linux 手札","Netkiller Java 手札"}); map.put("website", "http://www.netkiller.c...
相关文章
文章评论
共有0条评论来说两句吧...