Package org.elasticsearch.client

Examples of org.elasticsearch.client.IndicesAdminClient


  @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


     */
    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

                        }
                    } else {
                        logger.debug("Ignoring index: Name {} does not match the supported pattern ({})", index, pattern.pattern());
                    }

                    IndicesAdminClient indicesAdminClient = adminClient.indices();

                    if (!toClose.isEmpty()) {
                        logger.info("Closing indices: {}", toClose);
                        String[] indices = toClose.toArray(new String[toClose.size()]);
                        CloseIndexRequest req = indicesAdminClient.prepareClose(indices).request();
                        indicesAdminClient.close(req).actionGet();
                    }

                    if (!toDelete.isEmpty()) {
                        logger.info("Deleting indices: {}", toDelete);
                        String[] indices = toDelete.toArray(new String[toDelete.size()]);
                        DeleteIndexRequest req = indicesAdminClient.prepareDelete(indices).request();
                        indicesAdminClient.delete(req).actionGet();
                    }
                }


            } catch (ElasticsearchException e) {
View Full Code Here

        } catch (ElasticsearchException e) {
            // ok if the index didn't exist
        }

        // create mappings
        IndicesAdminClient admin = client.admin().indices();
        admin.prepareCreate(indexName).addMapping("doc", "x", "type=long", "y", "type=double");

        client.admin().cluster().prepareHealth(indexName).setWaitForGreenStatus().setTimeout("10s").execute().actionGet();
        return client;
    }
View Full Code Here

     */
    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

  private void createIndex(Site site) throws ContentRepositoryException,
      IOException {

    // Make sure the site index exists
    try {
      IndicesAdminClient indexAdmin = nodeClient.admin().indices();
      CreateIndexRequestBuilder siteIdxRequest = indexAdmin.prepareCreate(site.getIdentifier());
      logger.debug("Trying to create site index for '{}'", site.getIdentifier());
      CreateIndexResponse siteidxResponse = siteIdxRequest.execute().actionGet();
      if (!siteidxResponse.acknowledged()) {
        throw new ContentRepositoryException("Unable to create site index for '" + site.getIdentifier() + "'");
      }
View Full Code Here

TOP

Related Classes of org.elasticsearch.client.IndicesAdminClient

Copyright © 2018 www.massapicom. 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.