node client of elastic search笔记

Elasticsearch Java API Client 8.10.4 实战:Spring Boot 3.x 集成与 5 大核心操作封装 本文详细介绍了如何在Spring Boot 3.x项目中集成Elasticsearch Java API Client 8.10.4,并封装5大核心操作。内容涵盖版本兼容性、依赖配置、自动化Spring Boot集成、索引管理、文档CRUD、高级查询构建等实战技巧,以及生产环境下的连接池优化、异常处理和监控方案,最后通过电商商品搜索案例展示实际应用。 阅读详情

The node client, on the other hand, is actually a node within the cluster (but does not hold data, and cannot become master)(就是一个node,但是没有数据,也不是master). Because it is a node, it knows the entire cluster state (where all the nodes reside, which shards live in which nodes, and so forth). This means it can execute APIs with one less network hop(可以直接执行各种api,而且网络跳数更少).

If you need only a few long-lived, persistent connection objects to the cluster(只有几个到elastic search集群的长期的连接), a node client can be a bit more efficient since it knows the cluster layout. But it ties your application into the cluster, so it may pose problems from a firewall perspective.

NodeBuilder can also be used to connect to a cluster.

***建立NodeClient的方式***

Node node = nodeBuilder().clusterName("yourcluster").client(true).node();

Client client = node.client();

***备注:建立TransportClient的方式***

Client client = TransportClient.builder().build() .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300)) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300)); // on shutdown client.close();

 

 

It will join the cluster as another node and will be aware of the whole topology. Using nodes, you can use multicast to discover other running nodes(使用多播发现其它node,而不需要像transport client那样指定ip).

 

My opinion is that I prefer to use TransportClient than NodeClient because other cluster nodes won't receive useless information when the TransportClient stops. When a NodeClient stops, each node has to know that even if they don't have to manage it as it does not hold any data. Also, I have seen in debug mode that NodeClient starts more Threads than TransportCLient. So I think TransportClient has a lesser memory footprint. By the way, if you are using Spring, you can use the spring-elasticsearch factories for that. If not, you can always have a look at source code to see how I manage NodeClient vs TransportClient. Hope this helps.

EDIT 2016-03-09: NodeClient should not be used. If there is a need for that, people should create a client node (launch an elasticsearch node with node.data: false and node.master: false) and use a TransportClient to connect to it locally.(不要使用NodeClient类,而是直接在node上面跑transport client).

Currently we suggesting users create a Node (using NodeBuilder in 2.x) to have a client that is capable of keeping up-to-date information. This is generally a bad idea as it means elasticsearch has no control over eg max heap size or gc settings(堆大小的管理和gc设置), and is also problematic for users because they must deal with dependency collisions (and in 2.x+ dependencies of elasticsearch itself).

A better alternative, and what we should document, is to run a local elasticsearch server using bin/elasticsearch, and then use the transport client to connect to that local node(跑一个ealstic search node,并且在本地建立transport client连接). This local connection is virtually free, and allows the client code to be completely isolated from the elasticsearch process(用户线程和elasticsearch线程分开). Plugins are then also easy to deal with: just install them in elasticsearch as usual.

 

原文:

Transport Client Versus Node Client

 

If you are using Java, you may wonder when to use the transport client versus the node client. As discussed at the beginning of the book, the transport client acts as a communication layer between the cluster and your application. It knows the API and can automatically round-robin between nodes, sniff the cluster for you, and more. But it is external to the cluster, similar to the REST clients.

The node client, on the other hand, is actually a node within the cluster (but does not hold data, and cannot become master). Because it is a node, it knows the entire cluster state (where all the nodes reside, which shards live in which nodes, and so forth). This means it can execute APIs with one less network hop.

There are uses-cases for both clients:

  • The transport client is ideal if you want to decouple your application from the cluster. For example, if your application quickly creates and destroys connections to the cluster, a transport client is much "lighter" than a node client, since it is not part of a cluster.

    Similarly, if you need to create thousands of connections, you don’t want to have thousands of node clients join the cluster. The TC will be a better choice.

  • On the flipside, if you need only a few long-lived, persistent connection objects to the cluster, a node client can be a bit more efficient since it knows the cluster layout. But it ties your application into the cluster, so it may pose problems from a firewall perspective.
[源码解析] elastic search 8.0.0 的启动过程(二) 将截止到目前为止设计到的所有对象的配置文件收集起来,又是以list集合的方式, final List<Setting<?>> additionalSettings = new ArrayList<>(); 然后作为参数创建了一个NodeClient对象。如果Node是节点的静态表现方式,那NodeClient就是节点的动态表示方式,将会执行各种action。action是什么呢,我们到相应的场景再说,在这里可以简单理解为查询、新增文档等动作 Plugin是es中放 阅读详情

相关推荐

2025反爬终极方案:Python破解Cloudflare v2行为指纹,设备伪装+轨迹模拟拦截率压至1%

Cloudflare v2的反爬逻辑越来越接近“人类行为识别”,单纯的技术破解已失效,核心竞争力变成“模拟真实用户的能力”。本文的终极方案本质是“全方位复刻人类行为”——从设备指纹到操作轨迹,从网络特征到交互模式,让爬虫成为“无法被区分的真实用户”。这套方案的优势是“通用性强”,不仅适用于Cloudflare v2,也能破解大多数高反爬网站(如小红书、知乎、跨境电商)的行为检测;且代码可直接复用,新手只需替换目标URL和数据提取逻辑,就能快速落地。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2354

记一次生产环境elasticsearch排查问题的排查None of the configured nodes are available

今天其他组的同事过来说他们es生产环境报了一个错误,因为对es有一些了解所以叫我帮忙看看具体错误如下 以前我自己在测试的时候也有发现这个错,但是那时候是由于自己本地模拟集群环境,虚拟机的网络没调好,但是过一会就恢复了没在意,所以和他们说也许过一会就会恢复,但是到了中午他们正式环境还是有这个问题,一直不能解决。我第一个感觉是不是es挂了,于是上head插件排查了。由于这个组是后台的人员查询使用定

q3356564的博客 4万+

IQA图像质量评价 数据集介绍(LIVE、TID2013、CSIQ、LIVEC、KonIQ-10K)

LIVE、TID2013、CSIQ、LIVEC、KonIQ-10K 数据集介绍

qq_37925923的博客 1万+

(二)安装Elasticsearch单机服务 以及常见问题的解决

目录1 准备工作1.1 安装JDK1.2 下载安装包1.3 创建elastic用户2 启动ES服务2.1 修改配置文件3 验证ES服务是否可用4 关闭与重启服务4.1 关闭服务4.2 重启服务5 常见问题及解决方法5.1 使用ES专属用户登录时出错5.2 syscall filter - 不能安装5.3 memory is not locked - 内存没有锁定5.4 max virtual memory - 最大虚拟内存太小5.5 max number of threads - 最大线程数太小5.6 ma

hd20086996的博客 824

线阵相机标定必看:如何用Halcon实现亚毫米级精度测量(以HC050标定板为例)

本文以HC050标定板为例,详细阐述了如何利用Halcon实现线阵相机的高精度标定,以达到亚毫米级测量。文章深入剖析了线阵相机标定的核心原理、面临的独特挑战,并提供了从硬件搭建、图像采集到Halcon软件实操的完整路径,重点解析了运动参数设置、精度验证及常见问题排错,为精密测量应用提供系统解决方案。

weixin_29213655的博客 311

手把手教你用Alinx黑金开发板(Spartan-6)驱动ADF4351信号源(附Verilog SPI代码)

本文详细介绍了如何使用Alinx黑金开发板(Spartan-6 FPGA)驱动ADF4351信号源,包括硬件连接、Verilog SPI代码实现及系统调试。通过实战指南,帮助开发者快速掌握FPGA控制ADF4351芯片的技术,适用于射频信号源设计和学习应用。

weixin_30335575的博客 628

es构建客户端访问服务端数据时报NoNodeAvailableException[None of the configured nodes are available: [{#transport#

报错详情如下: NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{_sl7VF2cTb-iU0F9-UYqtQ}{域名}{xxxx:port}] ]at org.elasticsearch.client.transport.TransportClientNodesServ...

优快云2750的博客 886

电磁场仿真软件:Sonnet_(1).Sonnet软件概述

根据特定需求自定义仿真流程,如多频率点仿真、多边界条件仿真等。

kkchenjj的博客 1449

Elasticsearch问题:not part of the cluster,节点不属于集群问题

对于刚刚接触Elasticsearch的同学来说,可能会遇到不少问题,当然我也是了,我的这个问题是,Springboot 项目启动后,无法正常连接到Elasticsearch,但是在浏览器输入 http://10.57.133.253::9200 的时候是可以正常访问的,Idea Console的错误提示信息如下: 首先我说下我的环境吧,这个是很重要的一个部分,网上很多教程根本不说环境版本,导致...

学而时习之 1万+

29、网络支持技术:CDN、覆盖网络与无标度网络解析

本文详细解析了CDN路由方式与性能指标,探讨了覆盖网络与无标度网络的特性及其在云计算和现代网络中的应用。文章分析了CDN的关键技术与挑战,介绍了覆盖网络与小世界网络的基本原理,并深入讨论了无标度网络的构建算法、性能优化策略以及在多个领域的应用案例。最后,文章展望了未来网络技术发展趋势与无标度网络的结合潜力。

night的博客 88

【第07例】IPD体系进阶: 6 个技术评审点(TR)

TR技术评审点

产品线负责人 4415

springboot集成ElasticSearch时报错node not part of the cluster Cluster

springboot集成ElasticSearch时报错node not part of the cluster Cluster

qq_48817236的博客 734

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Elastic:开发者上手指南

你们好,我是Elastic的刘晓国。如果大家想开始学习Elastic的话,那么这里将是你理想的学习园地。在我的博客几乎涵盖了你想学习的许多方面。在这里,我来讲述一下作为一个菜鸟该如何阅读我的这些博客文章。 我们可以按照如下的步骤来学习: 1)Elasticsearch简介:对Elasticsearch做了一个简单的介绍 2)Elasticsearch中的一些重要概念:cluster,n..........................................................

Elastic 中国社区官方博客 17万+

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Elastic Search 从入门到跑路——入门篇

ElasticSearch 简介官网对 ElasticSearch 的介绍比较啰嗦,总结一下就是:1、Lucene 非常牛,但是不好使。2、ElasticSearch 封...

程序员吴小胖 2475

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Elastic Search 学习入门之生产环境下node.master和node.data的设置(三)

在生产环境下,如果不修改elasticsearch节点的角色信息,在高数据量,高并发的场景下,集群容易出现脑裂等问题。 默认情况下,elasticsearch集群中每个节点都有成为主节点的资格,也都存储数据,还可以提供查询服务。 这些功能是由两个属性控制的。分别是node.master和node.data 默认情况下这两个属性的值都是true。 下面详细介绍一下这两个属性的含义以及不同组合...

Ran_记忆犹新的博客 1850

为什么选择elastic.js?5大理由让你告别手写JSON查询DSL

如果你正在使用 Elasticsearch,却又为一大坨嵌套复杂的手写 JSON 查询 DSL 感到头疼,那么 **elastic.js** 就是为你准备的解决方案。它是一个用 JavaScript 实现的 Elasticsearch Query DSL 库,让你通过优雅的链式方法调用构建查询、过滤器和聚合,代码更清晰、更安全、更易维护。下面这 5 大理由,将告诉你为什么值得立刻上手。 📌 文

gitblog_00298的博客 460

IDM激活脚本IAS的3种模式与两条执行路径完整指南

IDM激活脚本(IAS)针对 Internet Download Manager 的 30 天试用限制,通过注册表键锁定方式提供冻结试用、激活与重置三条路径。冻结模式可以让试用不再到期,状态在更新、重启后保持。 ## 先把环境确认好 脚本官方支持 Windows 7/8/8.1/10/11 及其对应的 Server 版本,PowerShell 方式要求 Windows 8 及以上。 | 系统

gitblog_00040的博客 794

humanities-thesis-skill 开发者指南:30分钟写一个 source_xxx.py,接入你的新文献数据源

humanities-thesis-skill 是一个面向人文社科论文写作的 AI Skill,内置了 OpenAlex、CrossRef、知网等 8 个学术数据库的文献搜索能力。如果你想为它接入一个新的文献数据源(比如 JSTOR、ProQuest、Douban 读书或任何你常用的学术平台),只需要写一个 `source_xxx.py` 文件并注册两个函数。本文用 5 步带你从零完成一次**数据

gitblog_01169的博客 388

全文检索服务器Elastic Search入门

文章目录一、概述二、安装Elastic Search三、了解restful四、集成IK分词器五、命令操作六、Java操作Elastic Search 一、概述 和Lucene一样,都是用来做全文检索(创建索引和搜索索引).只是lucene是全文检索工具包,而ES是全文搜索服务器。 优点: 不仅支持java环境 es是服务器,它把原来lucene很复杂的操作封装成了Restful(http)接口.原来要写一大堆代码创建索引. 现在只需发一个http请求就OK(put http://127.0.0.1/use

weixin_46544297的博客 918

Elasticsearch Java Client 8.x 实战:Spring Boot 3.x 集成与 5 大核心 API 封装

本文详细介绍了如何在Spring Boot 3.x中集成Elasticsearch Java Client 8.x,并封装5大核心API实现企业级搜索解决方案。内容涵盖客户端配置、索引管理、文档CRUD、复杂查询构建、性能优化及监控等实战技巧,帮助开发者高效构建可维护的ES应用。

weixin_30443731的博客 321

go-elasticsearch 官方示例深度解析:用 TypedClient 调用 _search API 与两种分页策略

> 本文以官方仓库 `_examples/search` 示例为核心,系统讲解 go-elasticsearch(v9)typed client(`TypedClient`)调用 `_search` 的两种等效写法——`esdsl` 查询构造器与原生 `types.*` 结构体,并结合仓库源码剖析 `from + size` 与 `PIT + search_after` 两种分页方案的实现原理与适

gitblog_00334的博客 223

Elasticsearch可视化工具对比:es-client与Head的安装、功能与选型指南

在数据搜索与分析领域,Elasticsearch作为一款强大的分布式搜索引擎,其核心价值在于提供近乎实时的数据检索与聚合能力。其工作原理基于倒排索引和分片分布式存储,能够高效处理海量非结构化数据。对于开发者和运维人员而言,直接通过REST API或命令行操作ES虽然可行,但在日常的索引管理、查询调试和集群监控中,一个直观的可视化工具能极大提升工作效率。es-client和Head正是两款社区流行的ES可视化客户端,它们将复杂的DSL查询和集群状态以图形界面呈现,降低了使用门槛。es-client作为独立的桌

weixin_33858336的博客 459

Context Hub 中的 Elasticsearch JavaScript Client 9.x 编码指南:从认证初始化到全文检索、批量索引与聚合分析

本指南以 Context Hub 仓库中的 [Elasticsearch JavaScript 检索文档](https://link.gitcode.com/i/ff339fe038200959bb8e3e5b01900e94) 为主体,完整覆盖官方 `@elastic/elasticsearch` 客户端(9.2.0)的初始化认证、文档增删改查、Bulk 批量写入、全文/精确/布尔检索、聚合分析

gitblog_01002的博客 324

Elasticsearch Node.js 客户端(elasticsearch-js)完整使用指南:安装、连接、配置、CRUD 与版本兼容策略

本指南以官方开源仓库 `elasticsearch-js` 的 [README.md](https://link.gitcode.com/i/62294f24e472ae3ec9f04462e169e664) 为主线,系统讲解 Elasticsearch 官方 Node.js 客户端的本地快速上手、安装引入、连接与认证配置、索引与文档 CRUD 操作、版本兼容策略、Node.js 运行时支持范围,

gitblog_00374的博客 169
上一篇: Hbase Coprocessor导引笔记
下一篇: HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
cmdssd1
博客等级 码龄17年 24粉丝 46原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值