In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the difference and start of the Elasticsearch Java Client version. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
A brief summary:
If the server is below 5.6, choose the same version of TransportClient to avoid some API servers not supporting it.
If the server is above 5.6, choose the same version of RestClient
TransportClient start:
Version 5.6 and earlier:
/ / on startupClient client = TransportClient.builder () .build () .addTransportAddress (new InetSocketTransportAddress (InetAddress.getByName ("host1"), 9300) .addTransportAddress (new InetSocketTransportAddress (InetAddress.getByName ("host2"), 9300)); / / on shutdownclient.close ()
Version 6.0 and later:
/ / on startupTransportClient client = new PreBuiltTransportClient (Settings.EMPTY) .addTransportAddress (new TransportAddress (InetAddress.getByName ("host1"), 9300) .addTransportAddress (new TransportAddress (InetAddress.getByName ("host2"), 9300)); / / on shutdownclient.close () TransportClient sends search request: SearchResponse response = client.prepareSearch ("index1", "index2") .setTypes ("type1", "type2") .setSearchType (SearchType.DFS_QUERY_THEN_FETCH) .setQuery (QueryBuilders.termQuery ("multi") "test")) / / Query .setPostFilter (QueryBuilders.rangeQuery ("age"). From (12). To (18) / / Filter .setFrom (0) .setSize (60) .setExplain (true) .get () HttpClient start: / / Java Low Level REST ClientRestClient lowLevelRestClient = RestClient.builder (new HttpHost ("localhost", 9200, "http"), new HttpHost ("localhost", 9201, "http"). Build (); / / Java HighLevel REST ClientRestHighLevelClient client = new RestHighLevelClient (lowLevelRestClient); HttpClient sends search requests: SearchRequest searchRequest = new SearchRequest (); searchRequest.source (sourceBuilder); SearchResponse searchResponse = client.search (searchRequest) The above is the difference and start of the Elasticsearch Java Client version shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.