elasticsearch 7.6.1

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')

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值