
参考:
非常详细的阿里云服务器安装ElasticSearch过程..._阿里云服务器使用elasticsearch-CSDN博客
服务器平台:AutoDL
注意:
1、切换为非root用户,su 新用户名,否则ES无法启动
2、安装过程中没有出现设置账号密码,但请求时需要鉴权,可以关闭鉴权配置。
config-> elasticsearch.yml-> xpack.security.enabled false
创建索引:
curl -X PUT "http://localhost:9200/docs" -H "Content-Type: application/json" -d '
{
"mappings": {
"properties": {
"content": {
"type": "text"
}
}
}
}'
插入数据:
curl -X POST "http://localhost:9200/docs/_doc" -H "Content-Type: application/json" -d '
{
"content": "干完这个活就出门遛弯"
}'
通过python创建es对象,并且进行bm25检索
python
from elasticsearch import Elasticsearch
self.es_client = Elasticsearch("http://127.0.0.1:9200")
dsl = {
'query': {
'match': {
'content': "想出门遛弯"
}
},
"size": 3
}
search_result = self.es_client.search(index='docs', body=dsl)

本地kibana怎么连接远程ES
以AutoDL为例
注意:本地kibana和远程服务器上的ES版本号要一致
AutoDL提供的SS H通道。host:127.0.0.1,port: 6006

STEP 1 修改ES的config->elasticresearch.yml, host和port配置

STEP2 修改kibama的config->kibana.yml, 修改对应的es host信息

STEP 3 服务器启动ES,./bin/elasticsearch, 本地启动kibana ./bin/kibana
注意kibana config中server port , 浏览器打开http:localhost:5602

