ElasticSearch之——文件增刪改查
阿新 • • 發佈:2019-02-16
這裡,我們使用一個例項來說明,不多說,直接上程式碼:
#建立文件1 PUT /ecommerce/product/1 { "name" : "gaolujie yagao", "desc" : "gaoxiao meibai", "price" : 30, "producer" : "gaolujie producer", "tags": [ "meibai", "fangzhu" ] } #建立文件2 PUT /ecommerce/product/2 { "name" : "jiajieshi yagao", "desc" : "youxiao fangzhu", "price" : 25, "producer" : "jiajieshi producer", "tags": [ "fangzhu" ] } #建立文件3 PUT /ecommerce/product/3 { "name" : "zhonghua yagao", "desc" : "caoben zhiwu", "price" : 40, "producer" : "zhonghua producer", "tags": [ "qingxin" ] } #檢視文件 GET /ecommerce/product/1 #更新文件方式1,注意:此種方式必須傳遞文件的所有引數 PUT /ecommerce/product/1 { "name" : "jiaqiangban gaolujie yagao", "desc" : "gaoxiao meibai", "price" : 30, "producer" : "gaolujie producer", "tags": [ "meibai", "fangzhu" ] } #更新文件2,此種方式只需要傳遞待更新的欄位 POST /ecommerce/product/1/_update { "doc": { "name": "jiaqiangban gaolujie yagao" } } #刪除文件 DELETE /ecommerce/product/1