Alibabacloud.com offers a wide variety of articles about elasticsearch java client, easily find your elasticsearch java client information here online.
-ins1.Headthe head is a client plug-in used to monitor the Elasticsearch state.Installation: to the bin directory plugin install Mobz/elasticsearch-headAfter installation and then enter in the browser: http://localhost:9200/_plugin/head/, will open the following interface:
The figure shows a node Benedict Kine, each node has different index data, and the head
dynamically create a connection, which can hold the IP address of the Elasticsearch service client client=NULL; Try{string[] urllist= Url.split (","); ListNewArraylist(); for(String str:urllist) {logger.info (str); Inetsockettransportaddress transportaddress=NewInetsockettransportaddress (Inetaddress.getbyname (str), 9300); List.add (transportaddress)
Online API:Https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.4/transport-client.htmlTutorial:Http://blog.java1234.com/blog/articles/345.htmlAttention:different versions of the ES API differ significantly, the introduction of the jar package version must be consistent with production. tools and methods of use can refer to the spare Parts system proje
1. Add Maven DependencyXML code
dependency>
groupId>org.elasticsearchgroupId>
artifactid>elasticsearchartifactid>
version>0.90.0version>
Dependency>
It is recommended to use MAVEN to manage the project because Elasticsearch has a lot of dependencies and manual maintenance is cumbersome2. Create a client that connects to the Elasticsearch
Package Cn.test;import Java.net.inetaddress;import Java.net.unknownhostexception;import Org.elasticsearch.client.transport.transportclient;import Org.elasticsearch.common.settings.settings;import Org.elasticsearch.common.transport.inetsockettransportaddress;public class Elktest {//private static final String Cluster_Name = "Cluster_Name"; public static final String cluster_name = "Elasticsearch"; Instance name//private static final String IP
Elasticsearch is a Lucene-based search server. It provides a distributed multi-user-capable full-text search engine, based on a restful web interface. Elasticsearch is developed in Java, as the current popular enterprise-class search engine, used in cloud computing , can achieve real-time search, and has a stable, reliable, fast installation, ease of use and many
OverviewES supports groovy and Java two language custom score calculations, groovy can even be nested in the requested parameters, a little bit, but not in the scope of this discussion.How to use custom Java code to define how score is generated, which uses the ES plugin functionFor more information about the ES plugin, you can use the following command to obtain./bin e
Elasticsearch supports batch addition or deletion of index documents. In Java APIs, bulkrequestbuilder is constructed, batch index/delete requests are added to bulkrequestbuilder, and bulkrequestbuilder is executed. The following is an example:
Import static Org. elasticsearch. common. xcontent. xcontentfactory. *; bulkrequestbuilder bulkrequest =
First, install the plug-inTo delete all documents under one type of an index, this is equivalent to emptying the table operation in a relational database . Check out some of the information can be removed through the Delete-by-query plugin, first install the Delete-by-query plugin using the plugin manager:sudo bin/plugin install Delete-by-queryOffline mode similar to head, decompression placed under the elasticsearch/plugins/can be.When a cluster has
export documents in the index library to a file in JSON format, where the cluster name is "Bropen", the index library is named "blog", the type is "article", and the new Files/bulk.txt is created under the project root directory. Indexed content written in Bulk.txt:
Import Java.io.BufferedWriter;
Import Java.io.File;
Import Java.io.FileWriter;
Import java.io.IOException;
Import java.net.InetAddress;
Import java.net.UnknownHostException;
Import Org.elasticsearch.action.search.SearchResponse;
I
ES (Elasticsearch) suggester A total of four categories (term suggester, phrase suggester, completion suggester, context Suggester), Among them, completion suggester as the auto-completion function in the search box, especially used.This article will implement a simple example in the Java language to describe how to use completion suggester.The main function of the example is to create an auto-completion fu
Java official documentation for the main reference el: https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/generate.html
A blog: http://www.cnblogs.com/huangfox/p/3543134.html
Elasticsearch Official Guide: http://es.xiaoleilu.com/010_Intro/30_Tutorial_Search.ht
Elasticsearch Java API (ii): index create delete cluster managementElastic official website has the authoritative Java API English needs to be patient to see here to tidy up the basic operationCreate a MAVEN project to add dependencies First, customize a client to connect ES/*** Created by Forgeeks at 2017-03-22
/releasesTo download the version of the ES that you are using
IK version ES version
master 2.1.1-> master
1.7.0 2.1.1
1.6.1 2.1.0 1.5.0 2.0.0
1.4.1 1.7.2
1.4.0 1.6.0
1.3.0 1.5.0 1.2.9 1.4.0 1.2.8 1.3.2
1.2.7 1.2.1
1.2.6 1.0.0
1.2.5 0.90.x
1.1.3 0.20.x
1.1.2 0.19.x
1.0.0 0.16.2-> 0.19.0As shown above, individuals believe that a version of the high will be compatible with the low version
After the download is complete, unpack and then package using MVN package, where you need to install MAVEN,
The Elasticsearch (name is too long, hereafter referred to as ES) as a search engine, is now at its zenith, almost and Solr Qi Drive. There is no longer a description of what he can do with the cloud. However, the official ES of the documentation, especially on Java client documentation, is really little pathetic, even a complete deletion of the example of the c
Useful Links: Http://stackoverflow.com/questions/12215380/sorting-on-several-fields-in-elasticsearchSometimes, you need to set the order yourself, Java an interface is as follows:String time1 =constvalue.getcurrentdate (); Sortbuilder Sortbuilder = Sortbuilders.fieldsort ("Tfp_save_time"). Order (SORTORDER.DESC). ignoreunmapped (true /c2>); SearchResponse Scrollresp=client. Preparesearch ("flume-" + time1 +
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.