您当前的位置: 首页 >  搜索

少林码僧

暂无认证

  • 1浏览

    0关注

    317博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Elasticsearch跨集群搜索

少林码僧 发布时间:2021-12-07 17:49:18 ,浏览量:1

文章目录
    • 环境
    • 配置
    • 查询

环境

两个集群: 集群一: cluster_name: es1 node : 192.168.1.3:9300 ; 192.168.1.4:9300 集群二: cluster_name: es2 node : 192.168.1.5:9300 ; 192.168.1.6:9300

配置

通过集群一来主查询,则在集群一上进行配置。 集群配置:

PUT _cluster/settings
{
  "persistent" : {
    "cluster" : {
      "remote" : {
        "es2" : {
          "mode" : "sniff",
          "skip_unavailable" : "false",
          "node_connections" : "3",
          "seeds" : [
            "192.168.1.6:9300",
            "192.168.1.5:9300"
          ]
        }
      }
    }
  }
}
查询

在集群一查询:

GET *:test_index/_search    //代表查询所有远程集群索引名称为test_index
{
  "query": {
    "match": {
      "user_name": "岁"
    }
  }
}

GET es2:test_index/_search  //查询单个远程集群
{
  "query": {
    "match": {
      "user_name": "岁"
    }
  }
}

GET *:test_index,test_index/_search   //查询所有集群的索引
{
  "query": {
    "match": {
      "user_name": "岁"
    }
  }
}
关注
打赏
1661398670
查看更多评论
立即登录/注册

微信扫码登录

0.0409s