Package org.elasticsearch.client

Examples of org.elasticsearch.client.Client.admin()


    final InputStream mappings = Thread.currentThread().getContextClassLoader().getResourceAsStream("mappings.json");
    final InputStream index_settings = Thread.currentThread().getContextClassLoader().getResourceAsStream("index_settings.json");

    try {
      client.admin().indices().prepareCreate("photon").setSettings(IOUtils.toString(index_settings)).execute().actionGet();
      client.admin().indices().preparePutMapping("photon").setType("place").setSource(IOUtils.toString(mappings)).execute().actionGet();
    } catch(IOException e) {
      log.error("cannot setup index, elastic search config files not readable", e);
    }
  }
View Full Code Here


  public void setUp() throws Exception{
    node = NodeBuilder.nodeBuilder().local(true).node();
    Client client = node.client();
   
    try {
      client.admin().indices().prepareDelete("_river", "ldapserver0").execute().actionGet();
    } catch (IndexMissingException e) {
      // Ok
    }
   
    Thread.sleep(1000);
View Full Code Here

  private Client getSearchClient() {
    Settings settings = ImmutableSettings.settingsBuilder()
      .put("cluster.name", CLUSTER_NAME).build();
    Client client = new TransportClient(settings)
      .addTransportAddress(new InetSocketTransportAddress("localhost", port));
    assertThat(client.admin().cluster().prepareClusterStats().get().getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
    return client;
  }
}
View Full Code Here

  @Test
  public void test_custom_analyzer() {
        Client client = checkClient("esClient");

        GetSettingsResponse response = client.admin().indices().prepareGetSettings().get();
        assertThat(response.getSetting("twitter", "index.analysis.analyzer.francais.type"), is("custom"));
    }
}
View Full Code Here

  @Test
  public void test_template() {
    Client client = checkClient();

        GetIndexTemplatesResponse response = client.admin().indices().prepareGetTemplates().get();
        assertThat(response.getIndexTemplates().size(), is(1));
    }
}
View Full Code Here

  @Test
  public void test_number_of_shards() {
        Client client = checkClient();

        // We test how many shards and replica we have
        ClusterStateResponse response = client.admin().cluster().prepareState().execute().actionGet();
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfShards(), is(3));
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfReplicas(), is(2));
    }
}
View Full Code Here

   @Test
  public void test_multiple_nodes() {
    Client client = checkClient("testNodeClient");
    assertThat(client, instanceOf(org.elasticsearch.client.transport.TransportClient.class));

        NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().get();
        assertThat(nodeInfos.getNodes().length, is(2));
  }
}
View Full Code Here

    @Test
    public void test_alias() {
        Client client = checkClient();

        GetAliasesResponse response = client.admin().indices().prepareGetAliases().get();
        assertThat(response.getAliases().size(), is(2));
    }
}
View Full Code Here

  @Test
  public void test_merge_mapping() throws IOException {
    Client client = checkClient("esClient");
    checkClient("esClient2");

        MappingMetaData response = client.admin().indices().prepareGetMappings().get().getMappings().get("twitter").get("tweet");
        String mapping = new String(response.source().uncompressed());
        // This one comes from the first mapping
        assertThat(mapping, containsString("message"));
        // This one comes from the second mapping
        assertThat(mapping, containsString("author"));
View Full Code Here

        // See #31: https://github.com/dadoonet/spring-elasticsearch/issues/31
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfReplicas(), is(0));

        // Let's do the same thing with the second client
        // We test how many shards and replica we have
        response = client2.admin().cluster().prepareState().execute().actionGet();
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfShards(), is(1));

        // We don't expect the number of replicas to be 4 as we won't merge _update_settings.json
        // See #31: https://github.com/dadoonet/spring-elasticsearch/issues/31
        assertThat(response.getState().getMetaData().getIndices().get("twitter").getNumberOfReplicas(), is(0));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.