centos安装 文件下载 https://www.elastic.co/cn/downloads/kibana
下载链接 https://artifacts.elastic.co/downloads/kibana/kibana-7.6.1-linux-x86_64.tar.gz
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-linux-x86_64.tar.gz
https://blog.csdn.net/weixin_39800144/article/details/81162002
5.4以上需要jdk1.8以上版本
修改系统参数,参见https://blog.csdn.net/xiaoxiaoyu85/article/details/103391117中的自动化修改脚本
修改配置文件,打开host, port允许在非本机访问, cluster.initial_master_nodes: ["node-1"]
curl -XGET 'http://localhost:9200'
3)用root用户运行es会报错
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.
由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑, 建议创建一个单独的用户用来运行ElasticSearch
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch
cd elasticsearch文件夹目录
chown -R elsearch:elsearch elasticsearch
运行错误
http://blog.csdn.net/u012246178/article/details/63253531
切换到elsearch用户再启动
su elsearch cd elasticsearch/bin
./elasticsearch
在后台运行: ./bin/elasticsearch -d
#!/bin/bash
groupadd es
useradd es -g es -p es
chown -R es:es elasticsearch
集群搭建,使用cerebro可以管理集群
5.0之后的版本可以安装kibana作为管理配置平台
最新的不需要nodejs环境了
删除索引
DELETE /my-index
添加文档,索引重复的内容添加失败,但是更新成功, 不同的索引添加成功
PUT /gateway/help/1
{
"title": "如何添加分组",
"answer": "提交jira,通过审核后由管理员添加"
}
"result": "updated",
查找
GET /apihelp/help/_search
{
"query" : {
"match" : {
"answer" : "张三"
}
}
}
提示: 做精确匹配搜索时,你最好用过滤语句,因为过滤语句可以缓存数据。
match查询只能就指定某个确切字段某个确切的值进行搜索,而你要做的就是为它指定正确的字段名以避免语法错误。
多字段查找
GET _search{
"query": {
"multi_match": {
"query": "分组管理员",
"fields": [ "title", "answer" ]
}
}
}
python 调用ES
参考http://www.tuicool.com/articles/qaeqY3
#多字段查询
res = es.search(apiHelpIndex, body={"query": {"multi_match": {"query":"分组管理员","fields": [ "title", "answer" ]}}})
print res['hits']['hits'][0]['_source']['answer'].decode('utf8')
strRes = json.dumps(res, ensure_ascii=False)
print strRes.decode('utf-8')