use of io.searchbox.action.Action in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method getIndexStats.
@Override
public DocsStats getIndexStats(String indexName) {
Action getStats = new Stats.Builder().addIndex(indexName).build();
JestResult jestResult = jestClientHelper.executeAction(getStats);
Assert.isTrue(jestResult.isSucceeded(), jestResult.getErrorMessage());
JsonObject statsJson = jestResult.getJsonObject().getAsJsonObject("indices").getAsJsonObject(indexName).getAsJsonObject("primaries");
JsonObject docsJson = statsJson.getAsJsonObject("docs");
return new DocsStats(docsJson.get("count").getAsLong(), docsJson.get("deleted").getAsLong());
}
use of io.searchbox.action.Action in project jmxtrans by jmxtrans.
the class ElasticWriterTests method sendMessageToElasticWriteThrowsException.
@Test(expected = IOException.class)
public void sendMessageToElasticWriteThrowsException() throws Exception {
// return for call, is index created
when(mockClient.execute(isA(Action.class))).thenThrow(new IOException("Failed to add index entry to elastic."));
writer.doWrite(dummyServer(), dummyQuery(), ImmutableList.of(result));
// only one call is expected: the insert index entry. No write is being made with non-numeric values.
Mockito.verify(mockClient, times(1)).execute(Matchers.<Action<JestResult>>any());
}
use of io.searchbox.action.Action in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method isIndexExists.
@Override
public final boolean isIndexExists(String indexName) {
Action action = new IndicesExists.Builder(indexName).build();
JestResult result = jestClientHelper.executeAction(action);
return result.isSucceeded();
}
use of io.searchbox.action.Action in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method deleteIndex.
/**
* 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.executeAction(action);
LOGGER.info("Deleting Elasticsearch index, indexName={}. result successful is {} ", indexName, result.isSucceeded());
}
use of io.searchbox.action.Action in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method deleteDocumentById.
/**
* The delete document by id function will delete a document in the index by the document id.
*/
@Override
public final void deleteDocumentById(String indexName, String documentType, String id) {
LOGGER.info("Deleting Elasticsearch document from index, indexName={}, documentType={}, id={}.", indexName, documentType, id);
Action action = new Delete.Builder(id).index(indexName).type(documentType).build();
JestResult result = jestClientHelper.executeAction(action);
LOGGER.info("Deleting Elasticsearch document from index, indexName={}, documentType={}, id={} is successfully {}. ", indexName, documentType, id, result.isSucceeded());
}
Aggregations