here step is how to use elastic 8.3.1 on google colab.
download elastic, cgroup-tools¶
In [1]:
%%bash
rm -rf elasticsearch*
wget -q https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.3.1-linux-x86_64.tar.gz
tar -xzf elasticsearch-8.3.1-linux-x86_64.tar.gz
sudo chown -R daemon:daemon elasticsearch-8.3.1/
umount /sys/fs/cgroup
apt install cgroup-tools
start elastic on backgroud¶
In [2]:
%%bash --bg
sudo -H -u daemon elasticsearch-8.3.1/bin/elasticsearch
create access password¶
In [3]:
!/content/elasticsearch-8.3.1/bin/elasticsearch-setup-passwords auto -url "https://localhost:9200"
check a elastic process, live page. “Enter host password for user ‘elastic’:” use above elastic user password.¶
In [5]:
!ps -ef | grep elastic
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XGET https://localhost:9200/?pretty=true
create sample index.¶
In [10]:
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XPUT https://localhost:9200/playground -d '{"mappings": { "properties": { "name" : { "type": "keyword" } } } }'
check a index.¶
In [11]:
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XGET https://localhost:9200/playground/_mapping?pretty=true
create new data to es.¶
In [12]:
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XPOST https://localhost:9200/playground/_doc -d '{"name": "HOGE"}'