本地环境自建的es重启,http和https访问es,nested数据类型及设置es别名

news/2025/11/26 22:58:48/文章来源:https://www.cnblogs.com/oktokeep/p/19274898

本地环境自建的es重启,http和https访问es,nested数据类型及设置es别名

本地环境自建的es重启,http和https访问es,nested数据类型及设置es别名

link:
https接口的支持判断,http升级到https需求
https://www.cnblogs.com/oktokeep/p/19176975

1.测试环境es本地自建的,由于没有设置账号和密码,导致es数据泄露。所以将测试环境本地的es停止,导致本地的测试环境的订单列表查询报错。

查询进程是否存在:
root@VM-22-212-centos:/dd/log $ ps -ef | grep "9200"
root      2737  2481  0 11:00 pts/0    00:00:00 grep --color=auto 9200
root@VM-22-212-centos:/dd/log $ ps -ef | grep "9201"
root      2778  2481  0 11:00 pts/0    00:00:00 grep --color=auto 9201
root@VM-22-212-centos:/dd/log $ ps -ef | grep "9300"
root      2813  2481  0 11:00 pts/0    00:00:00 grep --color=auto 9300
root@VM-22-212-centos:/dd/log $ ps -ef | grep "elastic"
root      2921  2481  0 11:00 pts/0    00:00:00 grep --color=auto elasticroot@VM-22-212-centos:/dd/log $ netstat -lntp|grep 9301
root@VM-22-212-centos:/dd/log $ netstat -lntp|grep 9300
tcp6       0      0 :::9300                 :::*                    LISTEN      13549/java          
root@VM-22-212-centos:/dd/log $ netstat -lntp|grep 9200
tcp6       0      0 :::9200                 :::*                    LISTEN      13549/java          
root@VM-22-212-centos:/dd/log $ netstat -lntp|grep 9201启动命令:sudo systemctl restart elasticsearch查询服务器上面的历史命令并导出txt2018  2025-11-06 11:39:05 history >> history22.212.txt

访问:参考es访问控制

http访问方式

 

curl  -X GET "http://XX.16.22.XX:9200"   //以上截图的“内网访问地址”
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}curl -u elastic账号:es密码 -X GET "http://XX.16.22.XX:9200"6.8.2版本
root@VM-1-247-centos:~ $ curl -u elastic账号:es密码 -X GET "http://XX.16.22.XX:9200"
{"name" : "1762409755007608632","cluster_name" : "es-ioz97k9c","cluster_uuid" : "Gz7KD51RSnSlkvhFfuvTpQ","version" : {"number" : "6.8.2","build_flavor" : "default","build_type" : "zip","build_hash" : "bde2f6a","build_date" : "2025-09-08T13:32:47.932906Z","build_snapshot" : false,"lucene_version" : "7.7.0","minimum_wire_compatibility_version" : "5.6.0","minimum_index_compatibility_version" : "5.0.0"},"tagline" : "You Know, for Search"
}5.6.4版本
http://XX.16.22.YY:9200
curl -u elastic账号:es密码 -X GET "http://XX.16.22.YY:9200"
root@VM-1-247-centos:~ $ curl -u elastic账号:es密码 -X GET "http://XX.16.22.YY:9200"
{"name" : "1749716881004699232","cluster_name" : "es-6jzhzcxg","cluster_uuid" : "nXx5MYhZQIaPEb9nVZSlUQ","version" : {"number" : "5.6.4","build_hash" : "933ee86","build_date" : "2019-11-22T13:04:34.110Z","build_snapshot" : false,"lucene_version" : "6.6.1"},"tagline" : "You Know, for Search"
}

2.方案1,首先尝试将本地的es服务起来,然后再设置账号和密码,需要运维支持。
3.方案2,在腾讯云上面其实已经购买了云es的产品,需要考虑到es版本,es版本不对和http访问方式必须正确,否则es仍然会查询报错。
4.在腾讯云上面的es模块做数据备份,然后恢复到测试环境的es,这是一种方法。
手动快照备份
https://cloud.tencent.com/document/product/845/122407

手动备份

手动恢复

5.同时为了降低成本,将版本一致的es做了合并,方法同上,先备份,然后再恢复到另外一个target es服务中来。然后将引用原来source es的微服务,变更新的target es ip地址,然后重启微服务。线上自测观察,最终将source es 释放。

6.腾讯云上面的es 版本和http访问方式不对,运维重新购买一个新的,然后将老的释放。恢复同步的原则:es只能升级同步,不能降级同步数据。
7.更新ip es地址,调用微服务中的init初始化es接口,数据初始化,这样在管理后台的es 订单列表数据恢复。

8.在实际查询的过程中,根据车主订单列表查询需求,发现了一个nested数据类型不对的问题,原来init初始化的时候不会生成nested数据类型。
》》nested类型处理,重建索引。 查询的时候报错了。
设置别名,结合腾讯云的后台 备份,恢复来创建 order_v3来解决。

根本原因是这个数据类型不对导致: 已解决

原来的:
"ownerOrderViewList": {"properties": {"accountOwnerIncomeExamineList": {"ownerOrderList": {"properties": {"actRentTime": {"type": "date"解决后的:								
"ownerOrderViewList": {"type": "nested",
"ownerOrderList": {"type": "nested",	Caused by: org.elasticsearch.client.ResponseException: method [POST], host [http://XX.16.22.XX:9200], URI [/test_info/_search?rest_total_hits_as_int=true&typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&search_type=query_then_fetch&batched_reduce_size=512], status line [HTTP/1.1 400 Bad Request]

9.没有办法直接来修改es数据结构,在腾讯云的后台有操作界面,但是无法修改成功,个人认为:这个es数据结构已经存在数据了,而不是一个空的结构。
10.方法:将生产的一个order_v3的数据结构,同步到测试环境,检查数据结构中含有nested,ok

查询接口语法:
curl -u elastic账号:es密码 -X GET "http://XX.16.22.XX:9200/order_info/_mapping"//查询某个字段的mapping
curl -u elastic账号:es密码 -X GET "http://172.16.22.93:9200/order_info/_mapping/field/ownerOrderList" //需要带上*
curl -u elastic账号:es密码 -X GET "http://172.16.22.93:9200/order_info/_mapping/field/ownerOrder*"    这个可以查询出来。正解,需要带上/field

11.然后使用设置索引 es别名的方法,指向到新的order_v3,最终问题解决。

es索引管理

修改索引:		Reindex data from old index to new index:						
curl -u elastic账号:es密码 -X POST "http://XX.16.22.XX:9200/_reindex" -H 'Content-Type: application/json' -d '{"source": {"index": "order_info"},"dest": {"index": "order_v3"}}'# Add alias  Update aliases or switch to new index:
# 前提是存在了别名,先删除,然后再新增
curl -u elastic:es密码 -X POST "http://XX.16.22.XX:9200/_aliases" -H 'Content-Type: application/json' -d '{"actions": [{ "remove": { "index": "order_info", "alias": "order_info" } },{ "add": { "index": "order_v3", "alias": "order_info" } }]}'add,只新增别名:
curl -u elastic:es密码 -X POST "http://XX.16.22.XX:9200/_aliases" -H 'Content-Type: application/json' -d '{"actions": [{ "add": { "index": "order_v3", "alias": "order_info" } }]}'查看别名:
curl -u elastic:es密码 -X GET "http://XX.16.22.XX:9200/_cat/aliases"root@VM-22-216-centos:/ $ curl -u elastic:es密码 -X GET "http://XX.16.22.XX:9200/_cat/aliases"
.kibana      .kibana_1       - - -
car_property car_property_v3 - - -
.security    .security-6     - - -
order_info   order_v3   - - -

链接:
es创建索引及别名更新mapping方法 elasticsearch [nested] nested object under path [XXX] is not of nested type
https://www.cnblogs.com/oktokeep/p/14476798.html

12.nested查询语法片段

"nested": {"query": {"term": {"ownerOrderViewList.ownerMember.memNo": {"value": 967674718,"boost": 1.0}}},"path": "ownerOrderViewList","ignore_unmapped": false,"score_mode": "none","boost": 1.0
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/977741.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一文入门 LangChain 开发

2024-05-22 [[Ollama]] [[N_LangChain]] [[N_LangGraph]] LangChain github langchain 项目页 github langgraph 项目页 官方文档 introduction 官方文档 0.2 introductio 0.2 langserve 官方文档 0.1 Components La…

freedom of speech

but N cannot be bad. I think its just the difference between cultures.

七、设备模型

一、概述kobject内核抽象出来的通用对象,对应/sys目录下的一个文件 kset是kobject的一个扩展,一个kset尅包含多个kobject,将多个kobject通过parent进行关联,实现了层次化的结构 sysfs虚拟文件系统,向用户空间提供…

Scrum冲刺阶段 Day Three

一、站立会议纪要 1. 已完成工作 后端开发:设计用户与文件表结构 实现注册登录接口 实现文件上传接口 实现全局异常处理 封装请求拦截器前端开发:搭建前端基础框架 开发注册登录页面2. 今日计划工作实现文件列表查询…

鼎鉴时代锋芒 智启品牌新章 ——2025品牌智鉴榜荣耀登临

当全球产业重构与消费升级浪潮澎湃交汇,品牌早已成为衡量时代实力的核心标尺,更是穿越周期、引领变革的核心力量。2024 品牌智鉴榜,以 “智识为基、专业为刃、价值为魂”,历经百日全域筛查、多维体系核验、业界权威…

深入解析:MTK5G旗舰系列——天玑9500/9400/9300/9200/9000在AI和处理器性能、DDR频率及UFS的深度对比分析

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

迈向人机共育的文明语法:AI元人文理论体系深度阐释——内观照叙事模型

迈向人机共育的文明语法:AI元人文理论体系深度阐释——内观照叙事模型 我们正站在一个文明史的奇点上。人工智能不再是遥远的科幻,而是深度介入社会运作、伦理决策与意义构建的“文明参与者”。传统的“价值对齐”范…

Day25综合案例一--CSS精灵--京东服务

<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">…

Intellij扩展列表

开发idea插件,需要找到可用的扩展点,之前都是直接在网上搜索,最近详细看了下官方文档, 发现已经给我们列好了所有可用的扩展点 文档位置 https://plugins.jetbrains.com/docs/intellij/plugin-extensions.html#exp…

agentic terminal coding

opencode: https://github.com/sst/opencode The AI coding agent built for the terminalWhat is OpenCode? OpenCode is an open source agent that helps you write and run code directly from the terminal.[*] …

the badness of USA

it has no bad review. Maybe R/N/G can get the real worst some, but theres no even in the people they killed so much. so USA never changes. somehow.

Day3 Scrum冲刺博客

Day3 Scrum冲刺博客 1. 团队会议 todo补充会议照片 1)昨天已完成的工作前端实现个人设置弹窗以及问答模式静态页面,实现问答模式缓存 "关于我们"细节修正后端完成爬虫数据的数据清洗 增加爬虫程序适配的信…

完整教程:内核里常用宏BUG_ON/WARN_ON/WARN_ONCE

完整教程:内核里常用宏BUG_ON/WARN_ON/WARN_ONCE2025-11-26 22:27 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; displa…

贪心专题笔记(从b站左程云老师那上完后的笔记)

https://www.bilibili.com/video/BV1ST4y1s7XT/?spm_id_from=333.1007.top_right_bar_window_history.content.click&vd_source=56781f0f92104550238c449cb1aebd72 关键:用对数器验证 1.如果要排序,保证排序具有…

Agent编写全攻略(超详细)从零基础到精通,一篇搞定,不看后悔,赶紧收藏!

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

做题警醒

1.一定要写边界条件,不要偷懒不要偷懒!!! 经典案例题目https://www.luogu.com.cn/problem/P3763 这里一开始没把根节点单独考虑,直接将st1的赋值为0,st2的也复制为0 2.链式向前星建完图遍历是注意head[]写的是节点不…

动态规划可能性展开

1.以结尾展开可能性 从0……i中,判断i,然后调用0……i-1的可能性(可以是以i这个下标为结尾,也可以是0……i的范围上,也可以是以i下标所放的值进行展开) 2.定义往往从递归的定义出发,但是为了避免讨论边界的麻烦…

微软发布 Godot C# 游戏开发教程:godot-csharp-essentials

对于希望踏入游戏开发领域的 C# 开发者来说,一个令人振奋的好消息是:微软在其 GitHub 上发布了一个全新的开源项目microsoft/godot-csharp-essentials:https://github.com/microsoft/godot-csharp-essentials。这个仓…

Day3-20251126

本文介绍了Java开发相关的JDK、JRE和JVM概念,并详细说明了JDK的卸载和安装步骤。卸载时需删除安装目录和环境变量配置,安装时要注意下载对应版本并正确配置环境变量。最后通过cmd验证安装是否成功,并推荐使用notepa…