use of org.elasticsearch.action.index.IndexResponse in project elasticsearch by elastic.
the class SimpleBlocksIT method canIndexDocument.
private void canIndexDocument(String index) {
try {
IndexRequestBuilder builder = client().prepareIndex(index, "zzz");
builder.setSource("foo", "bar");
IndexResponse r = builder.execute().actionGet();
assertThat(r, notNullValue());
} catch (ClusterBlockException e) {
fail();
}
}
use of org.elasticsearch.action.index.IndexResponse in project sonarqube by SonarSource.
the class ProxyIndexRequestBuilderTest method index_with_index_type_and_id.
@Test
public void index_with_index_type_and_id() {
IndexResponse response = esTester.client().prepareIndex(FakeIndexDefinition.INDEX_TYPE_FAKE).setSource(FakeIndexDefinition.newDoc(42).getFields()).get();
assertThat(response.isCreated()).isTrue();
}
use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-opennlp-plugin by spinscale.
the class OpenNlpPluginIntegrationTest method testThatFacetingIsWorking.
@Test
public void testThatFacetingIsWorking() throws Exception {
putMapping("/test-mapping-analyzers.json");
String sampleText = copyToStringFromClasspath("/sample-text.txt");
IndexResponse indexResponse = indexElement(sampleText);
SearchResponse searchResponse = new SearchRequestBuilder(node.client()).setIndices(index).setTypes(type).setQuery(QueryBuilders.matchAllQuery()).addFacet(new TermsFacetBuilder("names").field("someFieldAnalyzed.name").order(TermsFacet.ComparatorType.TERM)).execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), is(1L));
assertThat(searchResponse.getHits().getAt(0).id(), is(indexResponse.getId()));
TermsFacet termsFacet = searchResponse.getFacets().facet(TermsFacet.class, "names");
assertThat(termsFacet.getTotalCount(), is(2L));
assertThat(termsFacet.getEntries().get(0).getTerm().string(), is("Jack Nicholson"));
assertThat(termsFacet.getEntries().get(1).getTerm().string(), is("Kobe Bryant"));
}
use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-graphite-plugin by spinscale.
the class GraphitePluginIntegrationTest method masterFailOverShouldWork.
@Test
public void masterFailOverShouldWork() throws Exception {
node = createNode(clusterName, GRAPHITE_SERVER_PORT, "1s");
String clusterName = UUID.randomUUID().toString().replaceAll("-", "");
IndexResponse indexResponse = indexElement(node, index, type, "value");
assertThat(indexResponse.getId(), is(notNullValue()));
Node origNode = node;
node = createNode(clusterName, GRAPHITE_SERVER_PORT, "1s");
graphiteMockServer.content.clear();
origNode.stop();
indexResponse = indexElement(node, index, type, "value");
assertThat(indexResponse.getId(), is(notNullValue()));
// wait for master fail over and writing to graph reporter
Thread.sleep(2000);
assertGraphiteMetricIsContained("elasticsearch." + clusterName + ".indexes." + index + ".id.0.indexing._all.indexCount 1");
}
use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-graphite-plugin by spinscale.
the class GraphitePluginIntegrationTest method testThatIndexingResultsInMonitoring.
@Test
public void testThatIndexingResultsInMonitoring() throws Exception {
node = createNode(clusterName, GRAPHITE_SERVER_PORT, "1s");
IndexResponse indexResponse = indexElement(node, index, type, "value");
assertThat(indexResponse.getId(), is(notNullValue()));
Thread.sleep(2000);
ensureValidKeyNames();
assertGraphiteMetricIsContained("^elasticsearch." + clusterName + ".indexes." + index + ".id.0.indexing._all.indexCount 1");
assertGraphiteMetricIsContained("^elasticsearch." + clusterName + ".indexes." + index + ".id.0.indexing." + type + ".indexCount 1");
assertGraphiteMetricIsContained("^elasticsearch." + clusterName + ".indexes." + index + ".id.0.search._all.queryCount ");
assertGraphiteMetricIsContained("^elasticsearch." + clusterName + ".node.jvm.threads.peakCount ");
assertGraphiteMetricIsContained("^elasticsearch." + clusterName + ".node.search._all.queryCount ");
}
Aggregations