日韩成人免费在线_国产成人一二_精品国产免费人成电影在线观..._日本一区二区三区久久久久久久久不

當前位置:首頁 > 科技  > 軟件

近期,幾個典型 Elasticsearch 8.X 問題及方案探討

來源: 責編: 時間:2024-02-01 12:50:54 215觀看
導讀問題1:max_expansions 設置大了會報錯,什么原因?大佬們問個問題,我在使用match_phrase_prefix時候,設置了一個比較大的max_expansions,比如10000。這個時候會報錯:too_many_clauses: maxClauseCount is set to 1024。我搜了

問題1:max_expansions 設置大了會報錯,什么原因?

大佬們問個問題,我在使用match_phrase_prefix時候,設置了一個比較大的max_expansions,比如10000。cIC28資訊網——每日最新資訊28at.com

這個時候會報錯:too_many_clauses: maxClauseCount is set to 1024。我搜了下 maxClauseCount 這是控制搜索條件數量的,但我這只是改了個 max_expansions 就這樣了,這2者有什么聯系呀?cIC28資訊網——每日最新資訊28at.com

根本原因:

如果你設置了一個很高的值( 10000),Elasticsearch 會嘗試生成所有可能的匹配項,直到達到這個限制。cIC28資訊網——每日最新資訊28at.com

而進行 match_phrase_prefix 查詢時,每個可能的匹配項都會被視為一個子句。cIC28資訊網——每日最新資訊28at.com

如果生成的匹配項數量超過 maxClauseCount 的限制,就會出現 too_many_clauses 錯誤。cIC28資訊網——每日最新資訊28at.com

可行的解決方案:

選擇一個更合理的 max_expansions 值,以保持生成的查詢子句數量在 maxClauseCount 的限制范圍內。cIC28資訊網——每日最新資訊28at.com

問題2:集群數據遷移能不能直接拷貝文件?

各位大佬,同版本的es集群間數據遷移,假設兩個集群節點數相同,是不是可以通過直接拷貝數據文件來進行啊?cIC28資訊網——每日最新資訊28at.com

去年年底咱們就討論過:臘月27日凌晨的一個緊急 Elasticsearch 線上問題復盤cIC28資訊網——每日最新資訊28at.com

一句話,非必要不要直接拷貝文件。cIC28資訊網——每日最新資訊28at.com

官方文檔在集群備份部分有過強調如下:cIC28資訊網——每日最新資訊28at.com

you cannot back up an Elasticsearch cluster by making copies of the data directories of its nodes. There are no supported methods to restore any data from a filesystem-level backup. If you try to restore a cluster from such a backup, it may fail with reports of corruption or missing files or other data inconsistencies, or it may appear to have succeeded having silently lost some of your data.cIC28資訊網——每日最新資訊28at.com

中文釋義:cIC28資訊網——每日最新資訊28at.com

  • 你無法通過復制其節點的數據目錄來備份 Elasticsearch 集群。
  • 不支持從文件系統級備份恢復任何數據的方法。
  • 如果你嘗試從此類備份恢復集群,則可能會失敗,并報告損壞或丟失文件或其他數據不一致的情況,或者可能看似已成功,但悄無聲息地丟失了一些數據。

https://discuss.elastic.co/t/why-are-we-told-to-copy-the-data-folder-when-upgrading/168951cIC28資訊網——每日最新資訊28at.com

https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshot-restore.htmlcIC28資訊網——每日最新資訊28at.com

問題3:全局超時如何設置?

除了每個search可以配置自己的timeout,集群有沒有參數可以配置一個統一的timeout,針對所有search都生效額?cIC28資訊網——每日最新資訊28at.com

建議:看看這個參數: search.default_search_timeout。cIC28資訊網——每日最新資訊28at.com

To set a cluster-wide default timeout for all search requests, configure search.default_search_timeout using the cluster settings API. This global timeout duration is used if no timeout argument is passed in the request. If the global search timeout expires before the search request finishes, the request is cancelled using task cancellation. The search.default_search_timeout setting defaults to -1 (no timeout).cIC28資訊網——每日最新資訊28at.com

圖片cIC28資訊網——每日最新資訊28at.com

cIC28資訊網——每日最新資訊28at.com

集群層面設置解決方案如下:cIC28資訊網——每日最新資訊28at.com

cIC28資訊網——每日最新資訊28at.com

圖片圖片cIC28資訊網——每日最新資訊28at.com

PUT /_cluster/settings{  "persistent": {    "search.default_search_timeout": "30s"  }}

要為所有搜索請求設置集群范圍內的默認超時時間,可以使用集群設置 API 配置 search.default_search_timeout。cIC28資訊網——每日最新資訊28at.com

如果請求中沒有傳遞超時參數,則使用這個全局超時持續時間。cIC28資訊網——每日最新資訊28at.com

如果全局搜索超時在搜索請求完成之前到期,請求將通過任務取消被取消。cIC28資訊網——每日最新資訊28at.com

search.default_search_timeout 設置的默認值為 -1(無超時)。cIC28資訊網——每日最新資訊28at.com

https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-your-data.html#search-timeoutcIC28資訊網——每日最新資訊28at.com

問題4:自定義ID如何自動設置為 MD5呢?

銘毅老師你好,想請問一下,往es索引里面插入文檔分為指定文檔id和自動生成文檔id,目前有一個需求在插入文檔的時候,將文檔的id值取插入的文檔中的一個字段。cIC28資訊網——每日最新資訊28at.com

比如我插入的是一個關于文件的相關信息的文檔,字段有md5值,大小,文件類型等等信息,此時我希望插入的這個文檔的ID是這個文件的md5值, 不太明白怎么設置這樣的關系,謝謝!cIC28資訊網——每日最新資訊28at.com

題目來源:https://t.zsxq.com/16mobA3PVcIC28資訊網——每日最新資訊28at.com

實踐參考:

Elasticsearch “指紋”去重機制,你實踐中用到了嗎?cIC28資訊網——每日最新資訊28at.com

方案:

使用 fingerprint 預處理器,借助已有的多個字段構建 MD5值,然后將目標字段設置為 _id 即可。cIC28資訊網——每日最新資訊28at.com

圖片圖片cIC28資訊網——每日最新資訊28at.com

cIC28資訊網——每日最新資訊28at.com

PUT _ingest/pipeline/id-fingerprint{  "processors": [    {      "fingerprint": {        "fields": ["file_name", "file_size"],        "target_field": "_id",        "method": "MD5"      }    }  ]}DELETE test_01128PUT test_01128{  "settings": {    "default_pipeline": "id-fingerprint"  },  "mappings": {    "properties": {      "file_name": {        "type": "keyword"      },      "id-fingerprint": {        "type": "keyword"      }    }  }}POST test_01128/_bulk{"index":{}}{"file_name":"abc","file_size":"3kb"}{"index":{}}{"file_name":"bcd","file_size":"1kb"}{"index":{}}{"file_name":"abc","file_size":"3kb"}

小結

以上都是實戰環境遇到的典型問題,如果你也有類似問題,歡迎發出來,咱們一起討論解決!cIC28資訊網——每日最新資訊28at.com

cIC28資訊網——每日最新資訊28at.com

本文鏈接:http://www.www897cc.com/showinfo-26-70445-0.html近期,幾個典型 Elasticsearch 8.X 問題及方案探討

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。郵件:2376512515@qq.com

上一篇: 看圖聊算法:為什么排序算法還是不夠快?

下一篇: 前端性能優化 — 保姆級 Performance 工具使用指南

標簽:
  • 熱門焦點
Top 主站蜘蛛池模板: 锡林郭勒盟| 旅游| 巴林右旗| 新郑市| 全椒县| 罗田县| 瑞丽市| 彭山县| 湖南省| 交城县| 万安县| 黔南| 沂南县| 腾冲县| 榆中县| 唐河县| 新宁县| 西吉县| 航空| 固阳县| 汉沽区| 兰州市| 灵丘县| 东港市| 苏尼特左旗| 伽师县| 佛坪县| 龙海市| 讷河市| 北票市| 永善县| 莱芜市| 伊宁县| 高密市| 托克逊县| 大英县| 凤山市| 海门市| 汨罗市| 贺兰县| 滦平县|