elasticsearch默认不能root用户启动解决方法

  • 修改其bin目录下elasticsearch文件,添加ES_JAVA_OPTS
    elasticsearch支持root启动

阿里云ECS中elasticsearch服务不能公网ip访问解决方法

  • 修改其conf目录下elasticsearch.yml文件,配置network.host:0.0.0.0
    elasticsearch支持公网ip访问
  • 按需限制访问,授权自己的公网ip访问9200端口
    elasticsearch笔记_第1张图片
    友情提示:如果家里路由器断电重启,请务必重新检查公网ip地址,并决定是否需要重新修改安全组授权公网ip地址。本来常识性觉得是网络供应商给用户提供的公网ip是不会随意变更的,家里停电重启后,本地redis客户端如何都连接不上云端redis服务端,检查阿里ECS安全组、redis服务、配置、服务器本地客户端调试,因为心里知道安全组有添加6379端口开放,配置也都设置好,最后测试其他服务,测了80端口也不通,但是22端口可以访问,重新检查安全组,证实22等端口默认开放全部ip,而自己设置的开放固定ip由于本地公网ip变更已经不一致,重新变更本地公网ip就可以正常访问了。

elasticsearch索引中文分词搜索不起作用注意点

  • 需要全文检索的属性,新建索引时注意,即使"_all"部分存在"analyzer",
    "search_analyzer"分词配置,"properties"中具体属性仍然需要单独专项"analyzer",
    "search_analyzer"分词配置,不然索引时分词不能正常运作,影响后期搜索。
// 测试环境
 curl -XDELETE http://127.0.0.1:9200/saletest
 curl -XPUT http://127.0.0.1:9200/saletest
 curl -XPOST  http://127.0.0.1:9200/saletest/saletest/_mapping -d'{
  "saletest": {
    "_all": {
      "enabled": true,
      "analyzer": "ik_max_word",
      "search_analyzer": "ik_max_word",
      "term_vector": "no",
      "store": "false"
    },
    "properties": {
      "content": {
        "type": "string",
        "index": "analyzed",
        "analyzer": "ik_max_word",
        "search_analyzer": "ik_max_word",
        "include_in_all": true
      }
    }
  }
}'

curl -XPOST http://127.0.0.1:9200/saletest/saletest/1 -d'{"content":"美国留给伊拉克的是个烂摊子吗"}'
curl -XPOST http://127.0.0.1:9200/saletest/saletest/2 -d'{"content":"公安部:各地校车将享最高路权"}'
curl -XPOST http://127.0.0.1:9200/saletest/saletest/3 -d'{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}'
curl -XPOST http://127.0.0.1:9200/saletest/saletest/4 -d'{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'

curl -XPOST http://127.0.0.1:9200/saletest/saletest/_search  -d'{
    "query" : { "term" : { "content" : "中国" }},
    "highlight" : {
      "pre_tags" : ["", ""],
      "post_tags" : ["", ""],
      "fields" : {
        "content" : {}
      }
    }
}'