io.searchbox.indices.DeleteIndex Java Examples

The following examples show how to use io.searchbox.indices.DeleteIndex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Jest.java    From easy-sync with Apache License 2.0 6 votes vote down vote up
public boolean deleteIndex(String indexName) {
    if(StringUtils.isBlank(indexName)){
        logger.warn("index name is blank");
        return false;
    }
    JestResult jr = null;
    try {
        //logger.info("delete index "+indexName);
        jr = jestClient.execute(new DeleteIndex.Builder(indexName).build());
        if (jr.isSucceeded() || jr.getResponseCode()==404) {
            return true;
        }
        logger.error("delete index  error :" + jr.getErrorMessage());
    } catch (IOException e) {
        logger.error("", e);
    }

    return false;


}
 
Example #2
Source File: JestServiceImpl.java    From EserKnife with Apache License 2.0 5 votes vote down vote up
@Override
public JestResult delIndex(String clustName, String indexName) {
    JestResult result = null ;
    try {
        DeleteIndex deleteIndex =new DeleteIndex.Builder(indexName).build();
        result = JestManager.getJestClient(clustName).execute(deleteIndex);
    } catch (Exception e) {
        e.printStackTrace();
        LOGGER.error("delIndex失败:",e);
    }
    return result ;
}
 
Example #3
Source File: ElasticsearchHelperService.java    From xmfcn-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 删除索引
 *
 * @param indexName
 * @throws Exception
 */
public JestResult deleteIndex(EsModel es) {
    JestResult result = null;
    RetData aReturn = validateParms(es);
    if (aReturn.getCode() == ResultCodeMessage.FAILURE) {
        return result;
    }
    String message = es.getMessage();
    String indexName = es.getIndex();
    String type = es.getType();
    result = indicesExists(indexName);
    if (result == null) {
        return result;
    }
    int responseCode = result.getResponseCode();
    if (responseCode != 200) {
        return result;
    }
    try {
        result = jestClient.execute(new DeleteIndex.Builder(indexName).build());
    } catch (Exception e) {
        String exceptionMsg = StringUtil.getExceptionMsg(e);
        logger.info(exceptionMsg);

    }
    return result;
}
 
Example #4
Source File: JestClient.java    From wES with MIT License 5 votes vote down vote up
@Override
public boolean delIndex(String index) throws Exception {
	try {
		JestResult result = _exec(new DeleteIndex.Builder(index).build());
		return result != null;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return false;
}
 
Example #5
Source File: IndexFunctionsDaoImpl.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * The delete index function will take as an argument the index name and will delete the index.
 */
@Override
public final void deleteIndex(String indexName)
{
    Action action = new DeleteIndex.Builder(indexName).build();

    LOGGER.info("Deleting Elasticsearch index, indexName={}.", indexName);
    JestResult result = jestClientHelper.execute(action);

    LOGGER.info("Deleting Elasticsearch index, indexName={}. result successful is {} ", indexName, result.isSucceeded());
}
 
Example #6
Source File: ManagerApiTestServer.java    From apiman with Apache License 2.0 5 votes vote down vote up
private void deleteAndFlush() throws IOException {
    if (client != null) {
        //System.out.println("FLUSH AND DELETE>>>>>>");
        client.execute(new DeleteIndex.Builder(ES_DEFAULT_INDEX).build());
        client.execute(new Flush.Builder().build());
        DefaultEsClientFactory.clearClientCache();
    }
}
 
Example #7
Source File: ESMetricsAccessorTest.java    From apiman with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
    File esDownloadCache = new File(System.getenv("HOME") + "/.cache/apiman/elasticsearch");
    esDownloadCache.getParentFile().mkdirs();

    locale = Locale.getDefault();
    Locale.setDefault(Locale.US);

    node = ApimanEmbeddedElastic.builder()
        .withPort(19250)
        .withElasticVersion(ApimanEmbeddedElastic.getEsBuildVersion())
        .withDownloadDirectory(esDownloadCache)
        .withSetting(PopularProperties.CLUSTER_NAME, "apiman")
        .withStartTimeout(1, TimeUnit.MINUTES)
        .withCleanInstallationDirectoryOnStop(true)
        .build()
        .start();

    // Delete, refresh and create new client
    client = createJestClient();
    client.execute(new DeleteIndex.Builder("apiman_metrics").build());
    client.execute(new Flush.Builder().force().build());
    DefaultEsClientFactory.clearClientCache();
    // Because of the delete above, the metrics fields need reinitialising with the index
    // mappings otherwise everything will screw up. See apiman_metrics-settings.json
    client = createJestClient();

    // Load test
    loadTestData();

    client.execute(new Flush.Builder().force().build());
    DefaultEsClientFactory.clearClientCache();
}
 
Example #8
Source File: JestTest.java    From springBoot-study with Apache License 2.0 2 votes vote down vote up
/**
* 删除索引
* @param indexName
* @return
* @throws Exception
*/
public boolean delete(JestClient jestClient,String indexName) throws Exception {  
    JestResult jr = jestClient.execute(new DeleteIndex.Builder(indexName).build());  
    return jr.isSucceeded();  
}
 
Example #9
Source File: JestTest.java    From java-study with Apache License 2.0 2 votes vote down vote up
/**
* 删除索引
* @param indexName
* @return
* @throws Exception
*/
public boolean delete(JestClient jestClient,String indexName) throws Exception {  
    JestResult jr = jestClient.execute(new DeleteIndex.Builder(indexName).build());  
    return jr.isSucceeded();  
}