ElasticSearch最佳入門實踐(六十)建立、修改以及刪除索引
1、建立索引
建立索引的語法
PUT /my_index
{
"settings": { ... any settings ... },
"mappings": {
"type_one": { ... any mappings ... },
"type_two": { ... any mappings ... },
...
}
}
示例
2、修改索引
PUT /my_index/_settings
{
"number_of_replicas": 1
}
3、刪除索引
DELETE /my_index
DELETE /index_one,index_two
DELETE /index_*
DELETE /_all
需要修改配置檔案
elasticsearch.yml
action.destructive_requires_name: true
相關推薦
ElasticSearch最佳入門實踐(六十)建立、修改以及刪除索引
1、建立索引 建立索引的語法 PUT /my_index { "settings": { ... any settings ... }, "mappings": { "type_one": { ... any mappings ...
ElasticSearch最佳入門實踐(三十)寫一致性原理以及quorum機制深入剖析
1、consistency,one(primary shard),all(all shard),quorum(default) 我們在傳送任何一個增刪改操作的時候,比如說put /index/type/id,都可以帶上一個consistency引數,指明我們想要的寫一致性是什
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最佳入門實踐(六十一)修改分詞器以及定製自己的分詞器
1、預設的分詞器 standard 其餘: standard tokenizer:以單詞邊界進行切分 standard token filter:什麼都不做 lowercase token filter:將所有字母轉換為小寫 stop token filer
ElasticSearch最佳入門實踐(六十五)基於scoll+bulk+索引別名實現零停機重建索引
1、重建索引 一個field的設定是不能被修改的,如果要修改一個Field,那麼應該重新按照新的mapping,建立一個index,然後將資料批量查詢出來,重新用bulk api寫入index中 批量查詢的時候,建議採用scroll api,並且採用多執行緒
ElasticSearch最佳入門實踐(六十四)索引管理_定製化自己的dynamic mapping
1、定製dynamic策略 true:遇到陌生欄位,就進行dynamic mapping false:遇到陌生欄位,就忽略 strict:遇到陌生欄位,就報錯 定製 PUT /my_index { "mappings": { "my_t
ElasticSearch最佳入門實踐(六十二)type底層資料結構
type,是一個index中用來區分類似的資料的,類似的資料,但是可能有不同的fields,而且有不同的屬性來控制索引建立、分詞器 field的value,在底層的lucene中建立索引的時候,全部是opaque bytes型別,不區分型別的 lucene是沒有
ElasticSearch最佳入門實踐(六十六)倒排索引組成結構以及其索引可變原因
倒排索引,是適合用於進行搜尋的 倒排索引的結構 (1)包含這個關鍵詞的document list (2)包含這個關鍵詞的所有document的數量:IDF(inverse document frequency) (3)這個關鍵詞在每個document中出現的次數:TF(ter
ElasticSearch最佳入門實踐(六十七)document寫入原理(buffer,segment,commit)
(1)資料寫入buffer (2)commit point (3)buffer中的資料寫入新的index segment (4)等待在os cache中的index segment被fsync強制刷到磁碟上 (5)新的index sgement被開啟,供search使用 (6)b
ElasticSearch最佳入門實踐(四十)分詞器的內部組成到底是什麼,以及內建分詞器的介紹
1、什麼是分詞器 一個分詞器,很重要,將一段文字進行各種處理,最後處理好的結果才會拿去建立倒排索引 切分詞語,normalization(提升recall召回率) 給你一段句子,然後將這段句子拆分成一個一個的單個的單詞,同時對每個單詞進行normalizat
ElasticSearch最佳入門實踐(七十)優化寫入流程實現海量磁碟檔案合併(segment merge,optimize)
每秒一個segment file,檔案過多,而且每次search都要搜尋所有的segment,很耗時 預設會在後臺執行segment merge操作,在merge的時候,被標記為deleted的document也會被徹底物理刪除 每次merge
ElasticSearch最佳入門實踐(五十)組合查詢
1、例子 GET /website/article/_search { "query": { "bool": { "must": [ { "match": { "title": "elasticsea
ElasticSearch最佳入門實踐(六十三)索引管理_mapping root object
1、root object 就是某個type對應的mapping json,包括了properties,metadata(_id,_source,_type),settings(analyzer),其他settings(比如include_in_all) PUT /
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最佳入門實踐(二十六)bulk批量增刪改
1、bulk語法 POST /_bulk { “delete”: { “_index”: “test_index”, “_type”: “test_type”, “_id”: “3” }} { “create”: { “_index”: “test_index”, “_typ
ElasticSearch最佳入門實踐(五十六)分散式搜尋引擎核心解密之query phase
1、query phase (1)搜尋請求傳送到某一個coordinate node,構構建一個priority queue,長度以paging操作from和size為準,預設為10 (2)coordinate node將請求轉發到所有shard,每個sha
ElasticSearch最佳入門實踐(六)案例實戰之電商網站商品管理:多種搜尋方式
1、query string search 搜尋全部商品 took:耗費了幾毫秒 timed_out:是否超時,這裡是沒有 _shards:資料拆成了5個分片,所以對於搜尋請求,會打到所有的primary shard(或者是它的某個replica shard也可以) hits.tot
ElasticSearch最佳入門實踐(四十二)什麼是mapping再次回爐透徹理解
(1)往es裡面直接插入資料,es會自動建立索引,同時建立type以及對應的mapping (2)mapping中就自動定義了每個field的資料型別 (3)不同的資料型別(比如說text和date),可能有的是exact value,有的是full text (4)exac
ElasticSearch最佳入門實踐(四十一)query string 的分詞以及 mapping 引入案例遺留問題的大揭祕
1、query string分詞 query string必須以和index建立時相同的analyzer進行分詞 query string對exact value和full text的區別對待 date:exact value _all:full text