Package org.elasticsearch.client

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


        assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));

        assertThat(client.prepareCount("_percolator").setQuery(matchAllQuery()).execute().actionGet().count(), equalTo(1l));

        client.admin().indices().prepareDelete("test").execute().actionGet();
        client.admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet();
        clusterHealth = client("node1").admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet();
        logger.info("Done Cluster Health, status " + clusterHealth.status());
        assertThat(clusterHealth.timedOut(), equalTo(false));
        assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));
View Full Code Here


            response.put("msg", "graph does not have graph elasticsearch index");

            return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
        }

        MetaData metaData = client.admin().cluster().prepareState()
                .setFilterIndices(graph.getIndexName())
                .execute()
                .actionGet()
                .getState()
                .getMetaData();
View Full Code Here

                        .delete(sessionId);

                final Object oneTime = data.get(ONE_TIME);
                if (oneTime != null) {
                    if (client != null) {
                        final DeleteMappingResponse deleteMappingResponse = client
                                .admin().indices()
                                .prepareDeleteMapping("_river")
                                .setType(riverName.name()).execute()
                                .actionGet();
                        if (deleteMappingResponse.isAcknowledged()) {
View Full Code Here

            client.prepareDeleteByQuery(indexName)
                    .setQuery(
                            QueryBuilders.termQuery("url",
                                    responseData.getUrl())).execute()
                    .actionGet();
            client.admin().indices().prepareRefresh(indexName).execute()
                    .actionGet();
        }

        @SuppressWarnings("unchecked")
        final Map<String, Object> arrayDataMap = (Map<String, Object>) dataMap
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public <T extends ActionResponse> T executeGet(final NodeCallback<T> callback) {
    final Client client = node.client();
    final IndicesAdminClient indicesAdmin = client.admin().indices();
    final ActionFuture<?> action = callback.execute(indicesAdmin);
    final T response = (T) action.actionGet();
    client.close();
    return response;
  }
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public <T extends ActionResponse> T executeGet(final ClusterCallback<T> callback) {
    final Client client = node.client();
    final ClusterAdminClient clusterAdmin = client.admin().cluster();
    final ActionFuture<?> action = callback.execute(clusterAdmin);
    final T response = (T) action.actionGet();
    client.close();
    return response;
  }
View Full Code Here

    TransportClient tmp = null;
    try {
      tmp = new TransportClient(snode);
      client = tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort)));
   
      if (!IndexExistsUtils.exists(client.admin().indices(), indexName)) {
        return false;
      }
      client.admin().cluster().health(new ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();
    }
    catch (Exception e) { // Index not alive...
View Full Code Here

      client = tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort)));
   
      if (!IndexExistsUtils.exists(client.admin().indices(), indexName)) {
        return false;
      }
      client.admin().cluster().health(new ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();
    }
    catch (Exception e) { // Index not alive...
      return false;
    }
    finally {
View Full Code Here

     * @return true if exists
     */
    public static boolean existsIndex(String indexName) {

        Client client = IndexClient.client;
        AdminClient admin = client.admin();
        IndicesAdminClient indices = admin.indices();
        IndicesExistsRequestBuilder indicesExistsRequestBuilder = indices.prepareExists(indexName);
        IndicesExistsResponse response = indicesExistsRequestBuilder.execute().actionGet();

        return response.isExists();
View Full Code Here

    final Client client = this.getClient();
    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

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.