wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install elasticsearch
編輯組態檔:
/etc/elasticsearch/elasticsearch.yml
network.host: 127.0.0.1
network.bind_host: 127.0.0.1
transport.tcp.port: 9300
http.port: 9200
/usr/share/elasticsearch/bin/elasticsearch -d
ES中使用restful api對資料進行增刪查改
1)GET:查詢資料
2)POST:插入或更改資料
3)PUT:創建庫或表
4)DELETE:洗掉庫
Index:資料庫
type:表
Document:行
Field:列,欄位
Mapping:元資訊
創建資料庫:http://localhost:9200/sinamail/ PUT
查看所有資料庫:http://localhost:9200/_cat/indices/ GET
洗掉資料庫:http://localhost:9200/sinamail/ DELETE
舊版本創建表,并且定義欄位:http://localhost:9200/sinamail/webmail/_mapping PUT
插入資料:
http://localhost:9200/sinamail/webmail/ POST
{
"accessLog": "測驗一下"
}
查詢資料:
http://localhost:9200/sinamail/_search POST
{"query":{"bool":{"must":[{"match":{"accessLog":"測驗下"}}]}},"from":0,"size":10}
使用CURL命令操作資料:
curl http://127.0.0.1:9200 查看狀態
curl -XPUT http://127.0.0.1:9200/sinamail 創建資料庫
curl http://127.0.0.1:9200/_cat/indices/ 查看所有資料庫
創建表,并且定義欄位
curl -XPUT http://127.0.0.1:9200/sinamail/webmail/_mapping -d '{ "webmail": { "properties": { "accessLog": { "type": "string" } } } }'
插入資料
curl -XPOST http://127.0.0.1:9200/sinamail/webmail -d '{ "accessLog":"我是一個好人的測驗" }'
查詢資料
curl -XPOST http://127.0.0.1:9200/sinamail/_search -d '{ "query":{ "bool":{ "must":[{"match":{"accessLog":"測我試下"}}]}},"from":0,"size":10 }'

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/102128.html
標籤:PHP
上一篇:PHP+Redis實作延遲任務,實作自動取消與完成訂單
下一篇:swoole行程間如何通信
