安装和启动:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.1.tar.gz
tar -xvf elasticsearch-6.0.1.tar.gz
cd elasticsearch-6.0.1/bin
./elasticsearch
在这里可能报错:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
那就创建一个用户:
adduser es #(userdel es)
passwd es #(12345678)
chown -R es /home/res/elasticsearch-6.0.1
su es
./elasticsearch -d #(后台启动)
查看状态:
curl -X GET "localhost:9200/_cat/health?v&pretty"
新增:
curl -X PUT "localhost:9200/customer?pretty&pretty"
添加文档:
curl -X PUT "localhost:9200/customer/doc/1?pretty&pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
更多的操作参见官网文档了: https://www.elastic.co/guide/index.html
在“Docs in Your Native Tongue”有语言的选择。
中文的好像是文档不是最新的。
不过够用就行了。
中文的文档:
https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html