mac 安裝 elasticsearch + 增刪改查

1.安裝:

屏幕快照 2017-09-17 下午4.03.27.png

啟動(dòng):

屏幕快照 2017-09-17 下午4.06.28.png

啟動(dòng)成功:

屏幕快照 2017-09-17 下午4.09.29.png
屏幕快照 2017-09-17 下午4.08.46.png

2.安裝head插件(提供web界面,基本信息的查看,rest請(qǐng)求的模擬,數(shù)據(jù)基本檢索):

安裝:
wget https://github.com/mobz/elasticsearch-head/archive/master.zip

屏幕快照 2017-09-17 下午4.17.35.png

安裝依賴包:
npm install

啟動(dòng):
npm run start

修改配置文件

屏幕快照 2017-09-17 下午6.02.42.png

這里可以配置主從

./bin/elasticsearch -d 后臺(tái)啟動(dòng)

3.索引>類型>文檔

索引創(chuàng)建

{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  },
  "mappings": {
    "man": {
      "properties": {
        "name": {
          "type": "text"
        },
        "country": {
          "type": "keyword"
        },
        "age": {
          "type": "integer"
        },
        "date": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-      dd||epoch_millis"
        }
      }
    },
    "woman": {}
  }
}

插入
1.指定文檔id插入 put
2.自動(dòng)產(chǎn)生文檔id插入 post
修改
1.直接修改文檔
2.腳本修改文檔


post
127.0.0.1:9200/people/man/1/_update

{
    "doc":{
        "name":"大黑" 
    }
}

post
127.0.0.1:9200/people/man/1/_update

{
    "script":{
        "lang":"painless",
        "inline":"ctx._source.age += 1"
    }
}

{
    "script":{
        "lang": "painless",
        "inline": "ctx._source.age = params.age",
        "params": {
            "age":100
        }
    }
}

刪除
1.刪除文檔
delete 127.0.0.1:9200/people/man/1
2.刪除索引
delete 127.0.0.1:9200/people

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容