= ImmutableSettings.settingsBuilder() .put("cluster.name", "myClusterName").build();Client client = new TransportClient(settings);//Add transport addresses and do something with the client...You can also use the elasticsearch.yml file to set.This client can sniff other parts of the cluster and add them to the list of machines. To turn on this feature, set client.transport.sniff to True.Settings settings = ImmutableSettings.settingsBuilder() .put("client.transport.sniff", true).
Elasticsearch provides a very comprehensive and powerful rest API that you can use to interact with your cluster. The few things you can do with the API are as follows:
Check your cluster, node, and index health status and statistics
Managing cluster, node, and index data and metadata
Perform crud (Create, read, update, and delete) indexes and se
The Elasticsearch query is to construct the QueryBuilder object in the Java API by executing the query criteria in JSON format, Elasticsearch fully supports the QUERYDSL style query, The QueryBuilder build class is the Querybuilders,filter build class is filterbuilders. The following is an example of constructing QueryBuilder:
Import static org.elasticsearch.inde
ElasticSearch java API-use More like this to implement Content-based recommendation
ElasticSearch java API-use More like this to implement Content-based recommendation
Content-based recommendations generally give a document information, and then recommend the documents that meet the document. Lucene's
]View PlainCopy
Searchhits hits = Myresponse.gethits ();
for (int i = 0; i
System.out.println (Hits.gethits () [I].getsourceasstring ());}
It can also use Hits.gethits () [I].getsource (), which is a map format that can be displayed in detailThird, the implementation of other APIs during the searchWhen we read the DSL, we can see that the query has a lot of queries, such as multi-domain, such as filtering query conditions, the following for the
].getsourceasstring ());}
It can also use Hits.gethits () [I].getsource (), which is a map format that can be displayed in detailThird, the implementation of other APIs during the searchWhen we read the DSL, we can see that the query has a lot of queries, such as multi-domain, such as filtering query conditions, the following for the Elasticsearch server development of some basic query DSL given in the Java A
First, Elasticsearch participle
In the Elasticsearch, the Chinese participle is supported, but all the participle is in accordance with the word word, such as the standard word breaker standard, you can follow the way to query how to do participle
Http://localhost:9200/iktest/_analyze?prettyanalyzer=standardtext= People's Republic of China
The above example uses the standard to carry on the participle, t
1, full-text query overview
Https://www.elastic.co/guide/en/elasticsearch/client/java-api/6.1/java-full-text-queries.html
The high-level full text queries are usually used to running full text queries on full text fields like the ' body of ' an EM Ail. They understand how the field being queried are analyzed and would apply each field ' analyzer (or Search_analyzer) to the Q Uery string before executing. 1
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.html
Key concepts of @xuguokun1986 code Understand the following nouns, as mentioned in the
":" String "}," raw ": {" type ":" string "," index ":" Not_analyzed "}}}}The above file says that we define its mapping for Index_type, the index type. The point is to map the name field to two, one to name the index analysis, and the other to not analyze raw, which will not split the phrase New York. So when we do the search, we can do the term aggregation for the Name.raw field and get the number of occurrences in all cities. Term Aggregation's The rest method requests are written as follows
are not active, in an unusable stateRed:Not all indexes primary shard are active, some indexes have data loss
indices
get/_cat/indices/index1?v
query For information about the specified index index1 (the number of Shard that comprise an index, the number of document, the number of doc deleted, the main memory size, and the total storage size for all indexes (including replicas) the number of document and the number of deleted document are lucense level
One, based on the HTTP protocol, in JSON for the data interactive format of the RESTful APIThe components that make the request to Elasticsearch are the same as other normal HTTP requests:Curl-xVerd http method: GET POST PUT HEAD DELETEPROTOCOL http or HTTPS protocolPort Elasticsearch HTTP service, default is 9200Path API paths (for example, _count will return th
Reprint: Http://m.blog.csdn.net/u012546526/article/details/74184769Elasticsearch Java API Common query Methods QueryBuilder Construction Example Environment Elasticsearch version5.1.1PomDependency> groupId>Org.elasticsearchgroupId> Artifactid>ElasticsearchArtifactid> version>5.1.1version>Dependency>Elasticsearch Index Mode number{ "type": "Long"}Strin
elasticsearch-5.x JAVA API Part II: Cluster Health and segment merging1. Cluster healthFirst define a class to store cluster health informationPackage Com.zw.elasticsearch.cluster;public class Clusterhealth {//Cluster name private String clustername; Number of nodes in cluster private int number_of_node; Active total number of pieces private int number_of_activeshards; Number of active primary shards
).curl localhost:9200/_bulk?pretty --data-binary @data.jsonSimilarly, if you follow the above definition of _index but do not define _type, then the index is test123 and the type is the type specified in our Curl command.Execute the above command curl http://localhost:9200/test123/test123/_bulk?pretty --data-binary @data.jsonGet the following results{ "took" : 1233, "errors" : false, "items" : [ { "index" : { "_index" : "test123", "_type" : "test123", "_id" : "1", "_ver
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.