当前位置: 首页 > 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…...

【C++学习手札】一文带你初识C++继承

食用指南:本文在有C基础的情况下食用更佳 🍀本文前置知识: C类 ♈️今日夜电波:napori—Vaundy 1:21 ━━━━━━️💟──────── 3:23 …...

【ubuntu18.04】01-network-manager-all.yaml和interfaces和resolv.conf各有什么区别和联系

文章目录 01-network-manager-all.yaml、interfaces 和 resolv.conf 是与网络配置相关的文件,它们在网络设置中有着不同的作用和使用方式。 01-network-manager-all.yaml: 这是一个配置文件,通常在 Ubuntu 系统上使用 NetworkManager 进行网络管理时使用…...

24近3年内蒙古大学自动化考研院校分析

今天给大家带来的是内蒙古大学控制考研分析 满满干货~还不快快点赞收藏 一、内蒙古大学 学校简介 内蒙古大学位于内蒙古自治区首府、历史文化名城呼和浩特市,距北京400余公里,是中华人民共和国成立后党和国家在民族地区创办的第一所综合大…...

大语言模型(LLM)与 Jupyter 连接起来了

现在,大语言模型(LLM)与 Jupyter 连接起来了! 这主要归功于一个名叫 Jupyter AI 的项目,它是官方支持的 Project Jupyter 子项目。目前该项目已经完全开源,其连接的模型主要来自 AI21、Anthropic、AWS、Co…...

ChatGLM2-6B在Windows下的微调

ChatGLM2-6B在Windows下的微调 零、重要参考资料 1、ChatGLM2-6B! 我跑通啦!本地部署微调(windows系统):这是最关键的一篇文章,提供了Windows下的脚本 2、LangChain ChatGLM2-6B 搭建个人专属知识库:提供…...

聊聊火车的发展

目录 1.火车的概念 2.火车的发展历史 3.火车对战争的影响 4.火车对人们出行造成的影响 1.火车的概念 火车是一种由机械动力驱动的陆上交通工具,通常用来运输人员和货物。它由一列或多列的连接在一起的车厢组成,有轨道作为其行驶的基础,并通…...

IDEA使用@Autowired为什么会警告?

在使用IDEA编写Spring相关的项目时,当在字段上使用Autowired注解时,总会出现一个波浪线提示:”Field injection is not recommended.” 这让我不禁疑惑:我每天都在使用这种方式,为何不被推荐呢?今天&#x…...

npm如何设置淘宝的镜像源模式

1. 查看当前npm的下载源 npm config get registry2. 全局配置npm使用淘宝镜像作为默认下载源 npm config set registry https://registry.npm.taobao.org --global3. 安装依赖包 npm install <package-name> 添加到devDependencies字段中&#xff1a; npm install &l…...

浅谈Redis的maxmemory设置以及淘汰策略

推荐阅读 AI文本 OCR识别最佳实践 AI Gamma一键生成PPT工具直达链接 玩转cloud Studio 在线编码神器 玩转 GPU AI绘画、AI讲话、翻译,GPU点亮AI想象空间 资源分享 「java、python面试题」来自UC网盘app分享&#xff0c;打开手机app&#xff0c;额外获得1T空间 https://dr…...

考虑分布式电源的配电网无功优化问题研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...