ES命令彙總

2021-09-29 13:26:16 字數 2847 閱讀 5359

1、檢視集群健康狀態

curl -x get "localhost:9200/_cat/health?v"
2、檢視集群健康狀態

curl -x get "localhost:9200/_cluster/health?pretty"
3、檢視集群中的節點

curl -x get "localhost:9200/_cat/nodes?v"
4、列出當前所有的索引

curl -x get "localhost:9200/_cat/indices?v"
5、建立索引

curl -x put "localhost:9200/customer?pretty"
6、刪除索引

curl -x delete "localhost:9200/customer?pretty"
7、設定資料型別

, "country_info": ,

"name": ,

"latitude": ,

"longitude": ,

"population": }}

}}'1、新增document'

2、查詢document

curl -x get "localhost:9200/customer/customer_info/1?pretty"
3、替換document'

4、更新document'

5、更新document---新增新字段}'

6、更新document---使用scripts指令碼更新'

注意:ctx代表被更新的物件本身

7、刪除document

curl -x delete "localhost:9200/customer/customer_info/2?pretty"
1、批量新增document}}

' 2、批量更新和刪除document} }

}'3、批量建立/更新index} }

}'4、批量建立create

} }'

注意:index 和 create 都可以增加文件。使用index時,如果記錄已存在,則會進行更新,如果不存在,則會新增;但是使用create時,如果記錄已存在,則會建立失敗!

5、批量更新update }}

}}'

6、批量刪除delete}}

' 7、批量獲取_mget

獲取索引teacher中,id為1,2的document(三種方式)

,

]}',

]}''

1、匹配刪除_delete_by_query

從索引teacher中刪除name為「evan」的document

}}'2、匹配更新_update_by_query

從索引teacher中,更新name包含「miltom」的文件,設定其gener=「boy」,age=100

},"script":

}}'匯入json檔案accounts.json到es中

}, "from":10,

"size":5,

"sort":[

],"_source":["account_number","balance"]}'

1、match查詢:查詢 account_number=20 的document

}}'2、match查詢:查詢 address 中包含 「mill」 的document

}}'3、match查詢:查詢 address 中包含 「mill」 或者 「lane」 的document

}}'4、match_phrase查詢:查詢 address 中包含短語 「mill lane」 的document

}}'注意:match與match_phrase的區別

5、bool and關係查詢:查詢address中同時包含「mill」與「lane」的document

}, }]}

}}'6、 bool or關係查詢:查詢address中同時包含「mill」與「lane」的document

}, }]}

}}'7、bool not關係查詢:查詢 address 中即不存在 「mill」 也不存在 「lane」 的document

}, }]}

}}'8、bool組合查詢:查詢 age=40,state!="id" 的document

} ],

"must_not":[}]

}}}'

9、bool filter查詢:查詢20000<=balance<=30000的document}}

}}}'

1、同時在bank,teacher兩個索引中搜尋

} }'

2、在所有索引中搜尋

},"size":100

}' }

}'1、查詢「title」中包含「search」,「content」中包含「elasticsearch」,「status」為「published」,「publish_date」>2015-01-01的文件

}, }

],"filter":[

},}}]}

}}'1、從"title","content"中搜尋"learn"

}}'

2、從"title","content"中搜尋"here"

}}' }}'

es索引命令

2.索引對映管理 3.索引別名 4.索引配置 5索引監控 6狀態管理 7.文件管理 put secisland delete secisland get secisland 返回內容 settings provided name secisland put secisland settings 說明...

es命令測試

1.新建索引並賦值 put 索引名 文件名 id 文件名後面會逐漸取消 相當表 put test1 type1 1 錯誤現象 使用 elasticsearch head 檢視 資料瀏覽 時,右側不出資料,使用瀏覽器f12檢視後,發現 406 not acceptable 錯誤。解決方法 1 進入 e...

ES6新特性彙總

const常量 num 10 常量不可修改,如果是物件的話,可以修改值 eg1 obj 可以直接將data從obj中解構出來 let obj eg2 let a 0 let b 1 如何交換二者的值?a,b b,a b 不錯 a 今天天氣 將變數直接 差值表示式的方式,插入字串中 let arr 1...