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
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/42388.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/42388.shtml
英文地址,請注明出處:http://en.pswp.cn/news/42388.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

WebGL游戲站優化實錄【myshmup.com】

myshmup.com 允許在瀏覽器中創建 shmup(射擊)游戲。 你可以使用具有創意通用許可證的資源或上傳自己的藝術作品和聲音。 創建的游戲可以在網站上發布。 該平臺不需要編碼,游戲對象的配置是在用戶界面的幫助下執行的。 后端是使用Django框架開…

機器學習筆記 - 使用 ResNet-50 和余弦相似度的基于圖像的推薦系統

一、簡述 這里的代碼主要是基于圖像的推薦系統,該系統利用 ResNet-50 深度學習模型作為特征提取器,并采用余弦相似度來查找給定輸入圖像的最相似嵌入。 該系統旨在根據所提供圖像的視覺內容為用戶提供個性化推薦。 二、所需環境 Python 3.x tensorflow ==2.5.0 numpy==1.21.…

星際爭霸之小霸王之小蜜蜂(三)--重構模塊

目錄 前言 一、為什么要重構模塊 二、創建game_functions 三、創建update_screen() 四、修改alien_invasion模塊 五、課后思考 總結 前言 前兩天我們已經成功創建了窗口,并將小蜜蜂放在窗口的最下方中間位置,本來以為今天將學習控制小蜜蜂,結…

GPT-4一紙重洗:從97.6%降至2.4%的巨大挑戰

斯坦福大學和加州大學伯克利分校合作進行的一項 “How Is ChatGPTs Behavior Changing Over Time?” 研究表明,隨著時間的推移,GPT-4 的響應能力非但沒有提高,反而隨著語言模型的進一步更新而變得更糟糕。 研究小組評估了 2023 年 3 月和 20…

win10安裝mysql和c++讀取調用舉例

一、下載mysql8.rar解壓到C盤(也可以解壓到其他位置) 在系統環境變量添加JAVA_HOMEC:\myslq8,并在path中添加%JAVA_HOME%\bin; 二、以管理員身份進入命令窗口 三、修改配置文件指定安裝路徑和數據庫的存放路徑 四、鍵入如下命令初始化并啟動mysql服務,然后修改登錄…

Rust之泛型、trait與生命周期

泛型是具體類型或其他屬性的抽象替代。在編寫代碼時,可以直接描述泛型的行為,或者它與其他泛型產生的聯系,而無須知曉它在編譯和運行代碼時采用的具體類型。 1、泛型數據類型: 們可以在聲明函數簽名或結構體等元素時使用泛型&am…

TDD(測試驅動開發)?

01、前言 很早之前,曾在網絡上見到過 TDD 這 3 個大寫的英文字母,它是 Test Driven Development 這三個單詞的縮寫,也就是“測試驅動開發”的意思——聽起來很不錯的一種理念。 其理念主要是確保兩件事: 確保所有的需求都能被照…

macOS Ventura 13.5.1(22G90)發布(附黑/白蘋果系統鏡像地址)

系統鏡像下載:百度:黑果魏叔 系統介紹 黑果魏叔 8 月 18 日消息,蘋果今日向 Mac 電腦用戶推送了 macOS 13.5.1 更新(內部版本號:22G90),本次更新距離上次發布隔了 24 天。 本次更新重點修復了…

Redis 緩存過期及刪除

一、Redis緩存過期策略 物理內存達到上限后,像磁盤空間申請虛擬內存(硬盤與內存的swap),甚至崩潰。 內存與硬盤交換 (swap) 虛擬內存,頻繁I0 性能急劇下降,會造成redis內存急劇下降; 一般設置物理內存的3/4,在redis…

內存不足V4L2 申請DMC緩存報錯問題

當內存不足時,V4L2可能存在申請DMA緩存報錯,如下日志: 13:36:54:125 [15070.640862] rkcifhw fdfe0000.rkcif: swiotlb buffer is full (sz: 1843200 bytes) 13:36:54:125 [15070.640891] rkcifhw fdfe0000.rkcif: swiotlb: coherent allocation failed, size=1843200 13:3…

超分辨率地震速度模型

文獻分享 1. Multitask Learning for Super-Resolution 原題目:Multitask Learning for Super-Resolution of Seismic Velocity Model 全波形反演(FWI)是估算地下速度模型的強大工具。與傳統反演策略相比,FWI充分利用了地震波的…

typedef

t y p e d e f typedef typedef 聲明&#xff0c;簡稱typedef&#xff0c;是創建現有類型的新名字。 比如&#xff1a; #include <bits/stdc.h> using namespace std; typedef long long ll; int main() {ll n;scanf("%lld",&n);printf("%lld"…

C++ 面向對象三大特性——多態

?<1>主頁&#xff1a;我的代碼愛吃辣 &#x1f4c3;<2>知識講解&#xff1a;C 繼承 ??<3>開發環境&#xff1a;Visual Studio 2022 &#x1f4ac;<4>前言&#xff1a;面向對象三大特性的&#xff0c;封裝&#xff0c;繼承&#xff0c;多態&#xff…

30W IP網絡有源音箱 校園廣播音箱

SV-7042XT是深圳銳科達電子有限公司的一款2.0聲道壁掛式網絡有源音箱&#xff0c;具有10/100M以太網接口&#xff0c;可將網絡音源通過自帶的功放和喇叭輸出播放&#xff0c;可達到功率30W。同時它可以外接一個30W的無源副音箱&#xff0c;用在面積較大的場所。5寸進口全頻低音…

RNN模型簡單理解和CNN區別

目錄 神經網絡&#xff1a;水平方向延伸&#xff0c;數據不具有關聯性 ? RNN&#xff1a;在神經網絡的基礎上加上了時間順序&#xff0c;語義理解 ?RNN: 訓練中采用梯度下降&#xff0c;反向傳播 ? 長短期記憶模型 ?輸出關系&#xff1a;1 toN&#xff0c;N to N 單入…

Spring三級緩存

目錄 循環依賴問題 三級緩存 三級緩存創建Bean的流程&#xff08;解決循環依賴問題&#xff09; 三級緩存的局限性 Spring的三級緩存是為了解決單例Bean的循環依賴問題而存在的。 循環依賴問題 簡單來說就是A依賴B&#xff0c;而B又依賴A。即創建A的時候&#xff0c;需要先…

【HarmonyOS】【DevEco Studio】ohpm安裝失敗該如何解決?

【關鍵詞】 HarmonyOS、DevEco Studio、ohpm安裝失敗 【問題背景及解決方案】 最近遇到很多DevEco Studio安裝ohpm失敗的問題&#xff0c;下面給大家介紹幾種出現的問題以及解決方案&#xff1a; 1、ohpm not set up&#xff0c;報錯截圖如下&#xff1a; ? 解決方案&…

一百六十、Kettle——Linux上安裝的Kettle9.2.0連接Hive3.1.2

一、目標 Kettle9.2.0在Linux上安裝好后&#xff0c;需要與Hive3.1.2數據庫建立連接 之前已經在本地上用kettle9.2.0連上Hive3.1.2 二、各工具版本 &#xff08;一&#xff09;kettle9.2.0 kettle9.2.0安裝包網盤鏈接 鏈接&#xff1a;https://pan.baidu.com/s/15Zq9w…

C++中class嵌套時構造函數,析構函數調用的順序

#include<iostream> using namespace std; class Phone { public:Phone(string pname){m_pnamepname;cout<<"phone的構造函數調用"<<endl;}~Phone(){cout<<"Phone的析構函數調用"<<endl;}string m_pname; }; class Person {…

網安周報|Monti Ransomware團伙推出了一個新的Linux加密器

Monti Ransomware團伙推出了一個新的Linux加密器 經過兩個月的休息&#xff0c;Monti 勒索軟件運營商帶著新的 Linux 版本的加密器返回。該變體被用于針對政府和法律部門組織的攻擊。研究人員注意到兩個團伙的TTP之間有多個相似之處&#xff0c;Monti運營商還基于Conti泄露的源…