ElasticSearch最佳入門實踐(二十四)partial update樂觀鎖併發控制原理以及相關操作
(1)partial update內建樂觀鎖併發控制
partial update內部是自動執行之前所說的樂觀鎖的併發控制方案
兩個執行緒
都拿到了document資料和_version
使用傳過來的field更新document
執行緒B也在做partial update 修改了資料,先寫回去了
這個時候執行緒A的操作 partial update 會 fail 掉
(2)retry_on_conflict策略
再次獲取最新資料和版本
基於最新資料和版本去更新,如果成功,那麼就OK了
如果失敗,則再次重複之前兩次操作
最多重複的次數可以通過 retry_on_conflict 引數去指定,比如 5 次
post /index/type/id/_update?retry_on_conflict=5&version=6
相關推薦
ElasticSearch最佳入門實踐(二十四)partial update樂觀鎖併發控制原理以及相關操作
(1)partial update內建樂觀鎖併發控制 partial update內部是自動執行之前所說的樂觀鎖的併發控制方案 兩個執行緒 都拿到了document資料和_version 使用傳過來的field更新document 執行緒B也在做partial update
ElasticSearch最佳入門實踐(三十四)multi-index & multi-type 搜尋模式解析以及搜尋原理解析
1、multi-index 和 multi-type 搜尋模式 告訴你如何一次性搜尋多個 index 和多個 type 下的資料 /_search:所有索引,所有type下的所有資料都搜尋出來 /index1/_search:指定一個ind
ElasticSearch最佳入門實踐(二十九)document增刪改內部原理揭祕
步驟 (1)客戶端選擇一個node傳送請求過去,這個node就是coordinating node(協調節點) (2)coordinating node,對document進行路由,將請求轉發給對應的node(有primary shard) (3)實際的node上的prima
ElasticSearch最佳入門實踐(二十八)剖析document資料路由原理
1、document路由到shard上是什麼意思? 我們這段,一個index的資料會被分為多片,每個片都在一個shard中,所以說,一個document存在於一個shard中 當客戶端建立的時候,es此時就需要決定說,這個document存在於那個shard上。 這個過程就稱
ElasticSearch最佳入門實踐(二十五)mget批量查詢api
1、批量查詢的好處 就是一條一條的查詢,比如說要查詢100條資料,那麼就要傳送100次網路請求,這個開銷還是很大的 如果進行批量查詢的話,查詢100條資料,就只要傳送1次網路請求,網路請求的效能開銷縮減100倍 2、mget的語法 可以說mget是很重要
ElasticSearch最佳入門實踐(二十七)總結以及什麼是distributed document store
1、總結 快速入門了一下,最基本的原理,最基本的操作 在入門之後,對ES的分散式的基本原理,進行了相對深入一些的剖析 圍繞著document這個東西,進行操作,進行講解和分析 2、什麼是distributed document s
ElasticSearch最佳入門實踐(二十六)bulk批量增刪改
1、bulk語法 POST /_bulk { “delete”: { “_index”: “test_index”, “_type”: “test_type”, “_id”: “3” }} { “create”: { “_index”: “test_index”, “_typ
ElasticSearch最佳入門實踐(五十四)相關度評分 TF & IDF 演算法解密
1、演算法介紹 relevance score演算法,簡單來說,就是計算出,一個索引中的文字,與搜尋文字,他們之間的關聯匹配程度 Elasticsearch使用的是 term frequency / inverse document frequency演算法
ElasticSearch最佳入門實踐(六十四)索引管理_定製化自己的dynamic mapping
1、定製dynamic策略 true:遇到陌生欄位,就進行dynamic mapping false:遇到陌生欄位,就忽略 strict:遇到陌生欄位,就報錯 定製 PUT /my_index { "mappings": { "my_t
ElasticSearch最佳入門實踐(三十九)倒排索引核心原理揭祕
1、例子,兩段文字 doc1:I really liked my small dogs, and I think my mom also liked them doc2:He never liked any dogs, so I hope that my m
ElasticSearch最佳入門實踐(三十八)精確匹配與全文搜尋的對比分析
1、ES中的兩種搜尋模式 1、exact value 2、full text 2、exact value 2017-01-01,exact value,搜尋的時候,必須輸入2017-01-01,才能搜尋出來。如果你輸入一個01,是搜尋不
ElasticSearch最佳入門實踐(三十七)用一個例子告訴你 mapping 到底是什麼
1、插入幾條資料 PUT /website/article/1 { "post_date": "2017-01-01", "title": "my first article", "content": "this is my first article in this w
ElasticSearch最佳入門實踐(三十六)query string search 語法以及 _all metadata 原理揭祕
1、query string基礎語法 GET /test_index/test_type/_search?q=test_field:test GET /test_index/test_type/_search?q=+test_field:test
ElasticSearch最佳入門實踐(三十五)分頁搜尋以及deep paging效能問題深度揭祕
1、如何使用es進行分頁搜尋的語法 size,from GET /_search?size=10 GET /_search?size=10&from=0 GET /_search?size=10&from=20 假設將這6條資料分成3頁,每一頁是2
ElasticSearch最佳入門實踐(三十一)document查詢內部原理揭祕
1、客戶端傳送請求到任意一個node,成為coordinate node 對於讀請求,不一定所有的請求都發送的primary shard 上去,也可以轉發到replied shard 上去,因為replied shard 也是可以服務所有讀請求的 2、coordin
ElasticSearch最佳入門實踐(六十九)優化寫入流程實現durability可靠儲存(translog,flush)
(1)資料寫入buffer緩衝和translog日誌檔案 (2)每隔一秒鐘,buffer中的資料被寫入新的segment file,並進入os cache,此時segment被開啟並供search使用 (3)buffer被清空 (4)重複1~3,新的segment不斷新增,buf
ElasticSearch最佳入門實踐(六十八)優化寫入流程實現NRT近實時(filesystem cache,refresh)
現有流程的問題,每次都必須等待fsync將segment刷入磁碟,才能將segment開啟供search使用,這樣的話,從一個document寫入,到它可以被搜尋,可能會超過1分鐘!!!這就不是近實時的搜尋了!!!主要瓶頸在於fsync實際發生磁碟IO寫資料進磁碟,是很耗時的。
ElasticSearch最佳入門實踐(五十七)分散式搜尋引擎核心解密之fetch phase
1、fetch phbase工作流程 (1)coordinate node構建完priority queue之後,就傳送mget請求去所有shard上獲取對應的document (2)各個shard將document返回給coordinate node
ElasticSearch最佳入門實踐(五十六)分散式搜尋引擎核心解密之query phase
1、query phase (1)搜尋請求傳送到某一個coordinate node,構構建一個priority queue,長度以paging操作from和size為準,預設為10 (2)coordinate node將請求轉發到所有shard,每個sha
ElasticSearch最佳入門實踐(五十五)核心級知識點之 doc value 初步探祕
搜尋的時候,要依靠倒排索引;排序的時候,需要依靠正排索引,看到每個document的每個field,然後進行排序,所謂的正排索引,其實就是doc values 在建立索引的時候,一方面會建立倒排索引,以供搜尋用;一方面會建立正排索引,也就是doc values,