Elastic Cloud に API でデータを投入する
10960 ワード
Credentials で private-key を調べます。
curl_insert.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
PRIVATE_KEY="private-***********"
NAME_ENGINE="blog-apr0102"
#
echo ${PRIVATE-KEY}
#
curl -X POST ${HOST}'/api/as/v1/engines/'${NAME_ENGINE}'/documents' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '${PRIVATE_KEY} \
-d@all_data.json
all_data.json
[
{
"id": "t001",
"name": "山本太郎",
"title": "My Name Is Yamato",
"content": "I love dog",
"tags": ["red", "green", "blue"]
},
{
"id": "t002",
"name": "田中康夫",
"title": "My Name Is Tanaka",
"content": "I love cat",
"tags": ["Earth", "Moon", "Mars"]
},
{
"id": "t003",
"name": "渡辺五郎",
"title": "My Name Is Watanabe",
"content": "I love fish",
"tags": ["apple", "orange", "banana"]
}
]
データの読み込み
Httpie
http_read.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
PRIVATE_KEY="private-******"
NAME_ENGINE="blog-apr0102"
#
http GET ${HOST}'/api/as/v1/engines/'$NAME_ENGINE'/documents/list' \
'Authorization: Bearer '${PRIVATE_KEY} < query00.json
query00.json
{
"page": {
"size": 5
}
}
Curl
curl_read.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
PRIVATE_KEY="private-******"
NAME_ENGINE="blog-apr0102"
#
#
curl -X GET ${HOST}'/api/as/v1/engines/'$NAME_ENGINE'/documents/list' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '${PRIVATE_KEY} \
-d '{
"page": {
"size": 5
}
}'
参考
Engines を API で取り扱う方法
参考ページ
Engines API
Create
create_engine.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
PRIVATE_KEY="private-********"
#
curl -X POST $HOST'/api/as/v1/engines' \
-H 'Authorization: Bearer '$PRIVATE_KEY \
-d '{"name": "blog-apr0102"}'
List
list_engines.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
PRIVATE_KEY="private-*******"
#
http $HOST'/api/as/v1/engines' \
'Authorization: Bearer '$PRIVATE_KEY
Delete
delete_engine.sh
HOST="https://mar29-project.ent.asia-northeast1.gcp.cloud.es.io"
PRIVATE_KEY="private-******"
NAME_ENGINE="blog-apr0102"
#
curl -XDELETE $HOST'/api/as/v1/engines/'$NAME_ENGINE \
-H 'Authorization: Bearer '$PRIVATE_KEY
参考
Python3 の例はこちら
Python3: Elastic Cloud に API でデータを投入する
Author And Source
この問題について(Elastic Cloud に API でデータを投入する), 我々は、より多くの情報をここで見つけました https://qiita.com/ekzemplaro/items/5591fa43c2dc39d47a6b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .