当前位置: 首页 > news >正文

es线上处理命令记录

常用命令

搜索

GET _search
{"query": {"match_all": {}}
}

获取全部模版

GET _index_template
GET _index_template/yst_crawler_template

获取全部索引

GET /_cat/indices?v 	

获取当前mapping

GET /yst_crawler/_mapping

创建一个mapping

PUT /yst_crawler
{"settings": {"number_of_shards": 1,"number_of_replicas": 1},"mappings": {"properties": {"id":{"type": "long"},"cover_url": {"type": "keyword"},"title": {"type": "text","analyzer": "english"},"create_at": {"type": "date","format": "epoch_second"},"article_time": {"type": "date","format": "epoch_second"},"milli_at": {"type": "date","format": "epoch_millis"}}}
}GET /yst_crawler/_mapping

删除一个索引

DELETE /yst_crawler

当前分词使用

POST /_analyze
{"analyzer": "standard","text": "In a polarized US, how to define a patriot increasingly depends on who’s being asked"}

查找数据

GET /yst_crawler/_search
{"query": { "match_all": {} },"sort": [{"milli_at": {"order": "desc"}}],"from": 0,"size": 20
}	

精确查询

GET /yst_crawler/_search
{"query": {"term": {"id": {"value": "1"}}}
}GET /yst_crawler/_search
{"query": {"bool": {"must": [{"match": {"title": "$20 million settlement"}},{"range": {"milli_at": {"gte": "now-30d/d","lte": "now/d"}}}]}},"sort": [{"milli_at": {"order": "desc"}}],"_source": ["id", "title", "milli_at", "s3_url", "article_time", "detail_url", "ref_id", "req_md5", "tags", "category", "content", "milli_at"],"from": 0,"size": 20
}GET /yst_crawler/_search
{"query": {"match_all": {}},"sort": [{"milli_at": {"order": "desc"}}],"_source": ["id", "title","milli_at","s3_url","article_time","detail_url","ref_id","req_md5","tags","category","content","milli_at"],"from": 0,"size": 10
}

媒体和分页查询

GET /yst_crawler/_search
{"query": {"bool": {"must": [{"match": {"title": "$20 million settlement"}},{"terms": {"ref_id": ["8fac888ae06647c3a7d6093c60c9d9b5"]}},{"range": {"milli_at": {"gte": "now-30d/d","lte": "now/d"}}}]}},"sort": [{"milli_at": {"order": "desc"}}],"_source": ["id", "title", "milli_at", "s3_url", "article_time", "detail_url", "ref_id", "req_md5", "tags", "category", "content", "milli_at"],"from": 0,"size": 20
}GET /yst_crawler/_search
{"query": {"match": {"id": "22111"}},"sort": [{"milli_at": {"order": "desc"}}],"_source": ["id", "title","milli_at","s3_url","article_time","detail_url","ref_id","req_md5","tags","category","content","milli_at"],"from": 0,"size": 20
}GET /yst_crawler/_search
{"query": {"bool": {"must": [{"match": {"title": "$20 million settlement"}},{"range": {"milli_at": {"gte": "now-30d/d","lte": "now/d"}}}]}},"sort": [{"milli_at": {"order": "desc"}}],"_source": ["id", "title", "milli_at", "s3_url", "article_time", "detail_url", "ref_id", "req_md5", "tags", "category", "content", "milli_at","article_id"],"from": 0,"size": 19
}GET /yst_crawler/_search
{"query": {"bool": {"must": [{"term": {"is_status": 0}},{"term": {"category": "for_you"}},{"range": {"milli_at": {"gte": "now-30d/d","lte": "1690362492000"}}}]}},"_source": ["id", "title", "milli_at", "s3_url", "article_time", "detail_url", "ref_id", "req_md5", "tags", "category", "content", "milli_at","article_id","desc","state"],"from": 0,"sort": [{"milli_at": {"order": "desc"}}],"size": 20
}

修改mapping

GET /yst_crawler/_mappingPUT /yst_crawler/_mapping
{"properties": {"state": {"type": "keyword"}}
}

查看setting

PUT /yst_city
{"settings": {"index.max_ngram_diff": 2,"analysis": {"analyzer": {"comma_analyzer": {"type": "pattern","pattern": ","},"code_ngram_analyzer": {"tokenizer": "code_ngram_tokenizer"}},"tokenizer": {"code_ngram_tokenizer": {"type": "ngram","min_gram": 2,"max_gram": 4}}}},"mappings": {"properties": {"id": {"type": "integer"},"state": {"type": "keyword"},"country": {"type": "keyword"},"city": {"type": "text"},"code": {"type": "text","analyzer": "comma_analyzer","fields": {"ngram": {"type": "text","analyzer": "code_ngram_analyzer"}}},"create_at": {"type": "integer"},"is_popular": {"type": "byte"},"sort": {"type": "short"},"location": {"type": "geo_point"}}}
}

搜索 city 和 code

GET /yst_city/_search
{"query": {"match": {"code": "36310"}},"_source": ["id","state","city","code","is_popular","location"],"from": 0,"size": 20
}GET /yst_city/_search
{"query": {"match": {"code.ngram": "31"}},"_source": ["id","state","city","code","is_popular","location"],"from": 0,"size": 20
}GET /yst_city/_search
{"query": {"bool": {"filter": [{"term": {"is_popular": 1}}]}},"sort": [{"sort": {"order": "asc"}}],"_source": ["id","state","city","code","is_popular","location"],"from": 0,"size": 20
}GET /yst_city/_search
{"query": {"function_score": {"query": {"query_string": {"default_field": "city","query": "e york"}},"field_value_factor": {"field": "is_popular","factor": 1.2,"modifier": "sqrt","missing": 1},"boost_mode": "multiply"}},"_source": ["id","state","city","is_popular","location"],"from": 0,"size": 20
}GET /yst_crawler/_search
{"query": {"term": {"title.keyword": {"value": "Man kicks in door, assaults ex-girlfriend: Solon Police Blotter"}}}
}GET /yst_crawler/_search
{"query": {"bool": {"must": [{"match": {"title": "110"}},{"range": {"milli_at": {"gte": "now-8d/d","lte": "now/d"}}}]}},"_source": ["id", "title", "milli_at", "s3_url", "article_time", "detail_url", "ref_id", "req_md5", "tags", "category", "content", "milli_at","article_id","desc"],"from": 0,"size": 10
}

认证分词

GET /yst_crawler/_analyze
{"analyzer": "my_custom_analyzer","text": "这里填入你想要分析的文本,例如:110"
}GET /yst_crawler/_analyze
{"analyzer": "standard","text": "这里填入你想要分析的文本,例如:110"
}POST /_analyze
{"tokenizer": "standard","filter": ["lowercase",{"type": "stop","stopwords": ["a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]}],"text": "hello 110th 10223"
}

删除一个模版

DELETE _index_template/yst_crawler_template

创建一个索引模版

该模版下,创建的索引前缀都会使用这个模版 yst_crawler

PUT _index_template/yst_crawler_template
{"index_patterns": ["yst_crawler*"],"template": {"settings": {"number_of_shards": 1,"number_of_replicas": 0,"analysis": {"filter": {"my_stop_filter": {"type": "stop","stopwords": ["a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]}},"analyzer": {"my_new_custom_analyzer": {"type": "custom","tokenizer": "standard","filter": ["lowercase","my_stop_filter"]}}}},"mappings": {"properties": {"id": {"type": "long"},"is_status": {"type": "byte"},"detail_url": {"type": "keyword"},"ref_id": {"type": "keyword"},"article_id": {"type": "keyword"},"tags": {"type": "text","analyzer": "english"},"s3_url": {"type": "keyword"},"title": {"type": "text","analyzer": "my_new_custom_analyzer","fields": {"keyword": {"type": "keyword"}}},"article_time": {"type": "date","format": "epoch_second"},"desc": {"type": "keyword"},"content": {"type": "keyword"},"milli_at": {"type": "date","format": "epoch_millis"},"category": {"type": "keyword"},"score": {"type": "integer"},"state": {"type": "keyword"}}}}
}

迁移工作

1.设置别名

POST /_aliases
{"actions": [{"add": {"index": "yst_crawler","alias": "yst_crawler_alias"}}]
}

2 .查看状态

GET yst_crawler/_statsPUT /yst_crawler_v2
GET /yst_crawler_v2/_mapping

3.验证分词

GET /yst_crawler_v2/_analyze
{"analyzer": "my_new_custom_analyzer","text": "xxx 110 2323"
}

4.把数据同步到新的索引

4.1 同步方式迁移
POST /_reindex
{"source": {"index": "yst_crawler"},"dest": {"index": "yst_crawler_v2"}
}
4.2 异步方式迁移,设置了9个并发
POST /_reindex?slices=9&refresh&wait_for_completion=false
{"source": {"index": "yst_crawler","size": 10000},"dest": {"index": "yst_crawler_v2"}
}
4.3 异步方式迁移,查看完成状态
GET /_tasksGET /_tasks/eiPlKw2_T3iKReTflMHkEQ:39797979

5.修改别名,去除别名

POST /_aliases
{"actions": [{"remove": {"index": "yst_crawler","alias": "yst_crawler_alias"}},{"add": {"index": "yst_crawler_v2","alias": "yst_crawler_alias"}}]
}

6.验证数据

主要看数据量total

GET yst_crawler/_stats
GET yst_crawler_v2/_stats

7.最后确认没问题后,删除老的索引

DELETE /yst_crawlerGET /_cat/indices?vGET /yst_crawler_alias/_search
{"query": {"bool": {"must": [{"match": {"title": "Pass State Park"}},{"range": {"milli_at": {"gte": "now-4d/d","lte": "now/d"}}}]}},"_source": ["id", "title", "milli_at", "s3_url", "article_time", "detail_url", "ref_id", "req_md5", "tags", "category", "content", "milli_at","article_id","desc"],"from": 0,"size": 20
}

相关文章:

es线上处理命令记录

常用命令 搜索 GET _search {"query": {"match_all": {}} }获取全部模版 GET _index_template GET _index_template/yst_crawler_template获取全部索引 GET /_cat/indices?v 获取当前mapping GET /yst_crawler/_mapping创建一个mapping PUT /yst_c…...

mysql 在nodejs中的简单使用(增删改查)

一 、封装SQL查询请求链接 const mysql require(mysql) //创建开发工具数据库链接池 const pool mysql.createPool({host: 192.168.1.133,user: user_name, password: 123456,database: database_name,port: 3306,connectionLimit: 50 // 限制连接数 });// sql:查…...

1.MySQL数据库的基本操作

数据库操作过程: 1.用户在客户端输入 SQL 2.客户端会把 SQL 通过网络发送给服务器 3.服务器执行这个 SQL,把结果返回给客户端 4.客户端收到结果,显示到界面上 数据库的操作 这里的数据库不是代表一个软件,而是代表一个数据集合。 显示当前的数据库 …...

Zabbix-6.4.4 邮箱告警SMS告警配置

目录 ​------------------------- # 邮箱告警 ---------------------------------- 1.安装mailx与postfix软件包 2.修改mailx配置文件 3. 创建文件夹 4. 编写mail-send.sh脚本 5. 将该脚本赋予执行权限 6. 进入web界面进行设置—> Alerts —> Media Types 7. 添…...

网络安全 Day30-运维安全项目-容器架构上

容器架构上 1. 什么是容器2. 容器 vs 虚拟机(化) :star::star:3. Docker极速上手指南1)使用rpm包安装docker2) docker下载镜像加速的配置3) 载入镜像大礼包(老师资料包中有) 4. Docker使用案例1) 案例01::star::star::…...

深入理解设计模式-创建型之单例模式

为什么要使用单例 1、表示全局唯一 如果有些数据在系统中应该且只能保存一份,那就应该设计为单例类。 如:配置类:在系统中,我们只有一个配置文件,当配置文件被加载到内存之后,应该被映射为一个唯一的【配…...

Vue中路由缓存问题及解决方法

一.问题 Vue Router 允许你在你的应用中创建多个视图,并根据路由来动态切换这些视图。默认情况下,当你从一个路由切换到另一个路由时,Vue Router 会销毁前一个路由的组件实例并创建新的组件实例。然而,有时候你可能希望保持一些页…...

Linux与bash(基础内容一)

一、常见的linux命令: 1、文件: (1)常见的文件命令: (2)文件属性: (3)修改文件属性: 查看文件的属性: ls -l 查看文件的属性 ls …...

NVIDIA Omniverse与GPT-4结合生成3D内容

全球各行业对 3D 世界和虚拟环境的需求呈指数级增长。3D 工作流程是工业数字化的核心,开发实时模拟来测试和验证自动驾驶车辆和机器人,操作数字孪生来优化工业制造,并为科学发现铺平新的道路。 如今,3D 设计和世界构建仍然是高度…...

Windows Server --- RDP远程桌面服务器激活和RD授权

RDP远程桌面服务器激活和RD授权 一、激活服务器二、设置RD授权 系统:Window server 2008 R2 服务:远程桌面服务 注:该方法适合该远程桌面服务器没网络状态下(离线),激活服务器。 一、激活服务器 1.打开远…...

关于游戏盾

游戏盾(Game Shield)是一种针对游戏行业特点的网络安全解决方案,主要针对游戏平台面临的各种网络攻击和安全威胁。以下是一些原因,说明为什么游戏平台需要加游戏盾: 1. DDoS攻击:游戏平台通常容易受到分布式…...

回归预测 | MATLAB实现基于SSA-KELM-Adaboost麻雀算法优化核极限学习机结合AdaBoost多输入单输出回归预测

回归预测 | MATLAB实现基于SSA-KELM-Adaboost麻雀算法优化核极限学习机结合AdaBoost多输入单输出回归预测 目录 回归预测 | MATLAB实现基于SSA-KELM-Adaboost麻雀算法优化核极限学习机结合AdaBoost多输入单输出回归预测预测效果基本介绍模型描述程序设计参考资料 预测效果 基本…...

《cpolar内网穿透》外网SSH远程连接linux(CentOS)服务器

本次教程我们来实现如何在外公网环境下,SSH远程连接家里/公司的Linux CentOS服务器,无需公网IP,也不需要设置路由器。 视频教程 [video(video-jrpesBrv-1680147672481)(type-csdn)(url-CSDN直播https://live-file.csdnimg.cn/release/live/…...

IDEA启动报错【java.sql.SQLSyntaxErrorException: ORA-00904: “P“.“PRJ_NO“: 标识符无效】

IDEA报错如下: 2023-08-17 11:26:15.535 ERROR [egrant-biz,b48324d82fe23753,b48324d82fe23753,true] 24108 --- [ XNIO-1 task-1] c.i.c.l.c.RestExceptionController : 服务器异常org.springframework.jdbc.BadSqlGrammarException: ### Error queryin…...

Nginx详解

1、高并发时代 单台tomcat在理想情况下可支持的最大并发数量在200~500之间,如果大于这个数量可能会造成响应缓慢甚至宕机。 解决方案是通过多台服务器分摊并发压力,这不仅需要有多台tomcat服务器,还需要一台服务器专门用来分配请求。这既是…...

摸清一下mysql授权语句的实际执行关系

样例 ---------------------------------------------------------------------- grant all PRIVILEGES on db1.* to test% identified by test1; grant all PRIVILEGES on db2.* to test% identified by test2; grant all PRIVILEGES on db3.* to test127.0.0.1 identified …...

sCrypt于8月12日在上海亮相BSV数字未来论坛

2023年8月12日,由上海可一澈科技有限公司(以下简称“可一科技”)、 临港国际科创研究院发起,携手美国sCrypt公司、福州博泉网络科技有限公司、复旦大学区块链协会,举办的BSV数字未来论坛在中国上海成功落下帷幕。 本次…...

Hbase的列式存储到底是什么意思?一篇文章让你彻底明白

一、 HBase 定义 Apache HBase™ 是以 hdfs 为数据存储的,一种分布式、可扩展的 NoSQL 数据库。 二、 HBase 数据模型 HBase 的设计理念依据 Google 的 BigTable 论文,论文中对于数据模型的首句介绍。 Bigtable 是一个稀疏的、分布式的、持久的多维排…...

机器学习|Softmax 回归的数学理解及代码解析

机器学习|Softmax 回归的数学理解及代码解析 Softmax 回归是一种常用的多类别分类算法,适用于将输入向量映射到多个类别的概率分布。在本文中,我们将深入探讨 Softmax 回归的数学原理,并提供 Python 示例代码帮助读者更好地理解和…...

EmbedPress Pro 在WordPress网站中嵌入任何内容

EmbedPress Pro可让您通过高级自定义、自定义品牌、延迟加载和更多惊人功能嵌入源。为古腾堡块和Elementor编辑器提供支持的一体化 WordPress 嵌入解决方案。使用 EmbedPress 在古腾堡创建交互式内容。使用 EmbedPress 的古腾堡块立即将任何内容嵌入到您的网站。 网址: EmbedP…...

1688商品列表API与其他数据源的对接思路

将1688商品列表API与其他数据源对接时,需结合业务场景设计数据流转链路,重点关注数据格式兼容性、接口调用频率控制及数据一致性维护。以下是具体对接思路及关键技术点: 一、核心对接场景与目标 商品数据同步 场景:将1688商品信息…...

Linux简单的操作

ls ls 查看当前目录 ll 查看详细内容 ls -a 查看所有的内容 ls --help 查看方法文档 pwd pwd 查看当前路径 cd cd 转路径 cd .. 转上一级路径 cd 名 转换路径 …...

将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?

Otsu 是一种自动阈值化方法,用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理,能够自动确定一个阈值,将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...

【算法训练营Day07】字符串part1

文章目录 反转字符串反转字符串II替换数字 反转字符串 题目链接&#xff1a;344. 反转字符串 双指针法&#xff0c;两个指针的元素直接调转即可 class Solution {public void reverseString(char[] s) {int head 0;int end s.length - 1;while(head < end) {char temp …...

Java求职者面试指南:Spring、Spring Boot、MyBatis框架与计算机基础问题解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、MyBatis框架与计算机基础问题解析 一、第一轮提问&#xff08;基础概念问题&#xff09; 1. 请解释Spring框架的核心容器是什么&#xff1f;它在Spring中起到什么作用&#xff1f; Spring框架的核心容器是IoC容器&#…...

MySQL 8.0 事务全面讲解

以下是一个结合两次回答的 MySQL 8.0 事务全面讲解&#xff0c;涵盖了事务的核心概念、操作示例、失败回滚、隔离级别、事务性 DDL 和 XA 事务等内容&#xff0c;并修正了查看隔离级别的命令。 MySQL 8.0 事务全面讲解 一、事务的核心概念&#xff08;ACID&#xff09; 事务是…...

AxureRP-Pro-Beta-Setup_114413.exe (6.0.0.2887)

Name&#xff1a;3ddown Serial&#xff1a;FiCGEezgdGoYILo8U/2MFyCWj0jZoJc/sziRRj2/ENvtEq7w1RH97k5MWctqVHA 注册用户名&#xff1a;Axure 序列号&#xff1a;8t3Yk/zu4cX601/seX6wBZgYRVj/lkC2PICCdO4sFKCCLx8mcCnccoylVb40lP...

02.运算符

目录 什么是运算符 算术运算符 1.基本四则运算符 2.增量运算符 3.自增/自减运算符 关系运算符 逻辑运算符 &&&#xff1a;逻辑与 ||&#xff1a;逻辑或 &#xff01;&#xff1a;逻辑非 短路求值 位运算符 按位与&&#xff1a; 按位或 | 按位取反~ …...

【iOS】 Block再学习

iOS Block再学习 文章目录 iOS Block再学习前言Block的三种类型__ NSGlobalBlock____ NSMallocBlock____ NSStackBlock__小结 Block底层分析Block的结构捕获自由变量捕获全局(静态)变量捕获静态变量__block修饰符forwarding指针 Block的copy时机block作为函数返回值将block赋给…...

2025年- H71-Lc179--39.组合总和(回溯,组合)--Java版

1.题目描述 2.思路 当前的元素可以重复使用。 &#xff08;1&#xff09;确定回溯算法函数的参数和返回值&#xff08;一般是void类型&#xff09; &#xff08;2&#xff09;因为是用递归实现的&#xff0c;所以我们要确定终止条件 &#xff08;3&#xff09;单层搜索逻辑 二…...