org.elasticsearch.client.transport.TransportClient.index()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(24.7k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.elasticsearch.client.transport.TransportClient.index()方法的一些代码示例,展示了TransportClient.index()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransportClient.index()方法的具体详情如下:
包路径:org.elasticsearch.client.transport.TransportClient
类名称:TransportClient
方法名:index

TransportClient.index介绍

暂无

代码示例

代码示例来源:origin: floragunncom/search-guard

@Test
public void testComposite() throws Exception {

  setup(Settings.EMPTY, new DynamicSgConfig().setSgConfig("sg_composite_config.yml").setSgRoles("sg_roles_composite.yml"), Settings.EMPTY, true);
  final RestHelper rh = nonSslRestHelper();

  try (TransportClient tc = getInternalTransportClient()) {                
    tc.index(new IndexRequest("starfleet").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();           
    tc.index(new IndexRequest("klingonempire").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();      
    tc.index(new IndexRequest("public").type("legends").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();            
  }
  
  String msearchBody = 
      "{\"index\":\"starfleet\", \"type\":\"ships\", \"ignore_unavailable\": true}"+System.lineSeparator()+
      "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+
      "{\"index\":\"klingonempire\", \"type\":\"ships\", \"ignore_unavailable\": true}"+System.lineSeparator()+
      "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator()+
      "{\"index\":\"public\", \"ignore_unavailable\": true}"+System.lineSeparator()+
      "{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator();
               
  HttpResponse resc = rh.executePostRequest("_msearch", msearchBody, encodeBasicHeader("worf", "worf"));
  Assert.assertEquals(200, resc.getStatusCode());
  Assert.assertTrue(resc.getBody(), resc.getBody().contains("\"_index\":\"klingonempire\""));
  Assert.assertTrue(resc.getBody(), resc.getBody().contains("hits"));
  Assert.assertTrue(resc.getBody(), resc.getBody().contains("no permissions for [indices:data/read/search]"));
  
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testSearchScroll() throws Exception {
  Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
    @Override
    public void uncaughtException(Thread t, Throwable e) {
      e.printStackTrace();
    }
  });
final Settings settings = Settings.builder()
    .putList(ConfigConstants.SEARCHGUARD_AUTHCZ_REST_IMPERSONATION_USERS+".worf", "knuddel","nonexists")
    .build();
setup(settings);
final RestHelper rh = nonSslRestHelper();
  try (TransportClient tc = getInternalTransportClient()) {
    for(int i=0; i<3; i++)
    tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
  }
  System.out.println("########search");
  HttpResponse res;
  Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executeGetRequest("vulcangov/_search?scroll=1m&pretty=true", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
  System.out.println(res.getBody());
  int start = res.getBody().indexOf("_scroll_id") + 15;
  String scrollid = res.getBody().substring(start, res.getBody().indexOf("\"", start+1));
  System.out.println(scrollid);
  System.out.println("########search scroll");
  Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/_search/scroll?pretty=true", "{\"scroll_id\" : \""+scrollid+"\"}", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
  System.out.println("########search done");
}

代码示例来源:origin: floragunncom/search-guard

tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();

代码示例来源:origin: floragunncom/search-guard

@Test
public void test557() throws Exception {
  final Settings settings = Settings.builder()
      .put(ConfigConstants.SEARCHGUARD_ROLES_MAPPING_RESOLUTION, "BOTH")
      .build();
  setup(Settings.EMPTY, new DynamicSgConfig(), settings);
  
  try (TransportClient tc = getInternalTransportClient(this.clusterInfo, Settings.EMPTY)) {
    
    tc.admin().indices().create(new CreateIndexRequest("copysf")).actionGet();
    
    tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
         tc.index(new IndexRequest("starfleet").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
         tc.index(new IndexRequest("starfleet_academy").type("students").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
    
  }
  
  final RestHelper rh = nonSslRestHelper();
  HttpResponse res = rh.executePostRequest("/*/_search", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":10}}}}", encodeBasicHeader("nagilum", "nagilum"));
  System.out.println(res.getBody());
  Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());  
  Assert.assertTrue(res.getBody().contains("starfleet_academy"));
  res = rh.executePostRequest("/*/_search", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":10}}}}", encodeBasicHeader("557", "nagilum"));
  System.out.println(res.getBody());
  Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());  
  Assert.assertTrue(res.getBody().contains("starfleet_academy"));  
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testTransportClientImpersonation() throws Exception {
  final Settings settings = Settings.builder()
      .putList("searchguard.authcz.impersonation_dn.CN=spock,OU=client,O=client,L=Test,C=DE", "worf", "nagilum")
      .build();
  setup(settings);
  try (TransportClient tc = getInternalTransportClient()) {
    tc.index(new IndexRequest("starfleet").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
    ConfigUpdateResponse cur = tc.execute(ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(new String[]{"config","roles","rolesmapping","internalusers","actiongroups"})).actionGet();
    Assert.assertEquals(clusterInfo.numNodes, cur.getNodes().size());
  }
  Settings tcSettings = Settings.builder()
      .put("searchguard.ssl.transport.keystore_filepath", FileHelper.getAbsoluteFilePathFromClassPath("spock-keystore.jks"))
      .put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_KEYSTORE_ALIAS,"spock")
      .put("path.home", ".")
      .put("request.headers.sg_impersonate_as", "worf")
      .build();
  try (TransportClient tc = getInternalTransportClient(clusterInfo, tcSettings)) {            
    NodesInfoRequest nir = new NodesInfoRequest();
    Assert.assertEquals(clusterInfo.numNodes, tc.admin().cluster().nodesInfo(nir).actionGet().getNodes().size());
  }
}

代码示例来源:origin: floragunncom/search-guard

@Test
  public void testCcsEmptyCoord() throws Exception {
    setupCcs();
    
    final String cl1BodyMain = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("", encodeBasicHeader("twitter","nagilum")).getBody();
    Assert.assertTrue(cl1BodyMain.contains("crl1"));
    
    final String cl2BodyMain = new RestHelper(cl2Info, false, false, getResourceFolder()).executeGetRequest("", encodeBasicHeader("twitter","nagilum")).getBody();
    Assert.assertTrue(cl2BodyMain.contains("crl2"));
    
    try (TransportClient tc = getInternalTransportClient(cl2Info, Settings.EMPTY)) {
      tc.index(new IndexRequest("twitter").type("tweet").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("0")
          .source("{\"cluster\": \""+cl2Info.clustername+"\"}", XContentType.JSON)).actionGet();
    }
    
    HttpResponse ccs = null;
    
    System.out.println("###################### query 1");
    ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/tweet/_search?pretty", encodeBasicHeader("twitter","nagilum"));
    System.out.println(ccs.getBody());
    Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());
    Assert.assertFalse(ccs.getBody().contains("security_exception"));
    Assert.assertTrue(ccs.getBody().contains("\"timed_out\" : false"));
    Assert.assertFalse(ccs.getBody().contains("crl1"));
    Assert.assertTrue(ccs.getBody().contains("crl2"));
    Assert.assertTrue(ccs.getBody().contains("cross_cluster_two:twitter"));
  }
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testMultiRoleSpan() throws Exception {
  
  setup();
  final RestHelper rh = nonSslRestHelper();
  try (TransportClient tc = getInternalTransportClient()) {    
    tc.index(new IndexRequest("mindex_1").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("mindex_2").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":2}", XContentType.JSON)).actionGet();
  }
  
  HttpResponse res = rh.executeGetRequest("/mindex_1,mindex_2/_search", encodeBasicHeader("mindex12", "nagilum"));
  System.out.println(res.getBody());
  Assert.assertEquals(HttpStatus.SC_FORBIDDEN, res.getStatusCode());
  Assert.assertFalse(res.getBody().contains("\"content\":1"));
  Assert.assertFalse(res.getBody().contains("\"content\":2"));
  
  try (TransportClient tc = getInternalTransportClient()) {                                       
    tc.index(new IndexRequest("searchguard").type("sg").id("config").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("config", FileHelper.readYamlContent("sg_config_multirolespan.yml"))).actionGet();
    ConfigUpdateResponse cur = tc.execute(ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(new String[]{"config"})).actionGet();
    Assert.assertEquals(clusterInfo.numNodes, cur.getNodes().size());
  }
  
  res = rh.executeGetRequest("/mindex_1,mindex_2/_search", encodeBasicHeader("mindex12", "nagilum"));
  System.out.println(res.getBody());
  Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());
  Assert.assertTrue(res.getBody().contains("\"content\":1"));
  Assert.assertTrue(res.getBody().contains("\"content\":2"));
  
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testUpdate() throws Exception {
  final Settings settings = Settings.builder()
      .put(ConfigConstants.SEARCHGUARD_ROLES_MAPPING_RESOLUTION, "BOTH")
      .build();
  setup(settings);
  final RestHelper rh = nonSslRestHelper();
  try (TransportClient tc = getInternalTransportClient()) {
    tc.index(new IndexRequest("indexc").type("typec").id("0")
        .setRefreshPolicy(RefreshPolicy.IMMEDIATE)
        .source("{\"content\":1}", XContentType.JSON)).actionGet();
  }
  HttpResponse res = rh.executePostRequest("indexc/typec/0/_update?pretty=true&refresh=true", "{\"doc\" : {\"content\":2}}",
      encodeBasicHeader("user_c", "user_c"));
  System.out.println(res.getBody());
  Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testCCSIndexResolve() throws Exception {
  
  setup();
  final RestHelper rh = nonSslRestHelper();
  try (TransportClient tc = getInternalTransportClient()) {                                       
    tc.index(new IndexRequest(".abc-6").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
  }
  
  HttpResponse res = rh.executeGetRequest("/*:.abc-6,.abc-6/_search", encodeBasicHeader("ccsresolv", "nagilum"));
  Assert.assertTrue(res.getBody(),res.getBody().contains("\"content\":1"));
  Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testMultiRoleSpan2() throws Exception {
  
  setup(Settings.EMPTY, new DynamicSgConfig().setSgConfig("sg_config_multirolespan.yml"), Settings.EMPTY);
  final RestHelper rh = nonSslRestHelper();
  try (TransportClient tc = getInternalTransportClient()) {                                       
    tc.index(new IndexRequest("mindex_1").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("mindex_2").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":2}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("mindex_3").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":2}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("mindex_4").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":2}", XContentType.JSON)).actionGet();
  }
  
  HttpResponse res = rh.executeGetRequest("/mindex_1,mindex_2/_search", encodeBasicHeader("mindex12", "nagilum"));
  Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());
  
  res = rh.executeGetRequest("/mindex_1,mindex_3/_search", encodeBasicHeader("mindex12", "nagilum"));
  Assert.assertEquals(HttpStatus.SC_FORBIDDEN, res.getStatusCode());
  res = rh.executeGetRequest("/mindex_1,mindex_4/_search", encodeBasicHeader("mindex12", "nagilum"));
  Assert.assertEquals(HttpStatus.SC_FORBIDDEN, res.getStatusCode());
   }

代码示例来源:origin: floragunncom/search-guard

tc.index(new IndexRequest("mindex1").type("type").id("1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("mindex2").type("type").id("2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":2}", XContentType.JSON)).actionGet();

代码示例来源:origin: floragunncom/search-guard

@Test
public void testRegexExcludes() throws Exception {
  
  setup(Settings.EMPTY, new DynamicSgConfig(), Settings.EMPTY);
  try (TransportClient tc = getInternalTransportClient(this.clusterInfo, Settings.EMPTY)) {
    tc.index(new IndexRequest("indexa").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"indexa\":1}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("indexb").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"indexb\":1}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("isallowed").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"isallowed\":1}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("special").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"special\":1}", XContentType.JSON)).actionGet();
    tc.index(new IndexRequest("alsonotallowed").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"alsonotallowed\":1}", XContentType.JSON)).actionGet();
  }
  
  RestHelper rh = nonSslRestHelper();
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("index*/_search",encodeBasicHeader("rexclude", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("indexa/_search",encodeBasicHeader("rexclude", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("isallowed/_search",encodeBasicHeader("rexclude", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executeGetRequest("special/_search",encodeBasicHeader("rexclude", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executeGetRequest("alsonotallowed/_search",encodeBasicHeader("rexclude", "nagilum")).getStatusCode());
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testDeleteByQueryDnfof() throws Exception {
  setup(Settings.EMPTY, new DynamicSgConfig().setSgConfig("sg_config_dnfof.yml"), Settings.EMPTY);
  try (TransportClient tc = getInternalTransportClient()) {                    
    for(int i=0; i<3; i++) {
      tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();        
    }
  }
  RestHelper rh = nonSslRestHelper();
  HttpResponse res;
  Assert.assertEquals(HttpStatus.SC_OK, (res=rh.executePostRequest("/vulcango*/_delete_by_query?refresh=true&wait_for_completion=true&pretty=true", "{\"query\" : {\"match_all\" : {}}}", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
  Assert.assertTrue(res.getBody().contains("\"deleted\" : 3"));
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testTransportClientImpersonationUsernameAttribute() throws Exception {
  final Settings settings = Settings.builder()
      .putList("searchguard.authcz.impersonation_dn.CN=spock,OU=client,O=client,L=Test,C=DE", "worf", "nagilum")
      .build();
  setup(Settings.EMPTY, new DynamicSgConfig().setSgConfig("sg_config_transport_username.yml")
      .setSgRolesMapping("sg_roles_mapping_transport_username.yml")
      .setSgInternalUsers("sg_internal_users_transport_username.yml")
      , settings);
  try (TransportClient tc = getInternalTransportClient()) {
    tc.index(new IndexRequest("starfleet").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
    ConfigUpdateResponse cur = tc.execute(ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(new String[]{"config","roles","rolesmapping","internalusers","actiongroups"})).actionGet();
    Assert.assertEquals(clusterInfo.numNodes, cur.getNodes().size());
  }
  Settings tcSettings = Settings.builder()
      .put("searchguard.ssl.transport.keystore_filepath", FileHelper.getAbsoluteFilePathFromClassPath("spock-keystore.jks"))
      .put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_KEYSTORE_ALIAS,"spock")
      .put("path.home", ".")
      .put("request.headers.sg_impersonate_as", "worf")
      .build();
  try (TransportClient tc = getInternalTransportClient(clusterInfo, tcSettings)) {            
    NodesInfoRequest nir = new NodesInfoRequest();
    Assert.assertEquals(clusterInfo.numNodes, tc.admin().cluster().nodesInfo(nir).actionGet().getNodes().size());
  }
}

代码示例来源:origin: floragunncom/search-guard

@Test
public void testSingle() throws Exception {

  setup();

  try (TransportClient tc = getInternalTransportClient()) {          
    tc.index(new IndexRequest("shakespeare").type("type").id("1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
         
    ConfigUpdateResponse cur = tc.execute(ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(new String[]{"config","roles","rolesmapping","internalusers","actiongroups"})).actionGet();
    Assert.assertEquals(clusterInfo.numNodes, cur.getNodes().size());
  }

  RestHelper rh = nonSslRestHelper();
  //sg_shakespeare -> picard

  HttpResponse resc = rh.executeGetRequest("shakespeare/_search", encodeBasicHeader("picard", "picard"));
  System.out.println(resc.getBody());
  Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode());
  Assert.assertTrue(resc.getBody().contains("\"content\":1"));
  
  resc = rh.executeHeadRequest("shakespeare", encodeBasicHeader("picard", "picard"));
  Assert.assertEquals(HttpStatus.SC_OK, resc.getStatusCode());
  
}

代码示例来源:origin: floragunncom/search-guard

tc.index(new IndexRequest("esb-prod-1").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("esb-prod-2").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":2}", XContentType.JSON)).actionGet();            
tc.index(new IndexRequest("esb-prod-3").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":3}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("esb-prod-4").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":4}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("esb-prod-5").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":5}", XContentType.JSON)).actionGet();

代码示例来源:origin: floragunncom/search-guard

tc.index(new IndexRequest("vulcangov").type("type").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();

代码示例来源:origin: floragunncom/search-guard

@Test
public void testAliasResolution() throws Exception {
  final Settings settings = Settings.builder()
      .build();
  setup(settings);
  final RestHelper rh = nonSslRestHelper();
  try (TransportClient tc = getInternalTransportClient()) {                    
    tc.index(new IndexRequest("concreteindex-1").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();                
    tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("concreteindex-1").alias("calias-1"))).actionGet();
    tc.index(new IndexRequest(".kibana-6").type("doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();                
    tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices(".kibana-6").alias(".kibana"))).actionGet();
  }
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("calias-1/_search?pretty", encodeBasicHeader("aliastest", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("calias-*/_search?pretty", encodeBasicHeader("aliastest", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("*kibana/_search?pretty", encodeBasicHeader("aliastest", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest(".ki*ana/_search?pretty", encodeBasicHeader("aliastest", "nagilum")).getStatusCode());
  Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest(".kibana/_search?pretty", encodeBasicHeader("aliastest", "nagilum")).getStatusCode());
}

代码示例来源:origin: floragunncom/search-guard

tc.index(new IndexRequest("theindex").type("type1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("otherindex").type("type1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().alias("alias1").filter(QueryBuilders.termQuery("_type", "type1")).index("theindex"))).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().alias("alias2").filter(QueryBuilders.termQuery("_type", "type2")).index("theindex"))).actionGet();

代码示例来源:origin: floragunncom/search-guard

tc.index(ir).actionGet();

相关文章

微信公众号

最新文章

更多