Search in sources :

Example 26 with IndexResponse

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();
    }
}
Also used : IndexRequestBuilder(org.elasticsearch.action.index.IndexRequestBuilder) IndexResponse(org.elasticsearch.action.index.IndexResponse) CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 27 with IndexResponse

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();
}
Also used : IndexResponse(org.elasticsearch.action.index.IndexResponse) Test(org.junit.Test)

Example 28 with IndexResponse

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"));
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) TermsFacetBuilder(org.elasticsearch.search.facet.terms.TermsFacetBuilder) CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) IndexResponse(org.elasticsearch.action.index.IndexResponse) TermsFacet(org.elasticsearch.search.facet.terms.TermsFacet) SearchResponse(org.elasticsearch.action.search.SearchResponse) Test(org.junit.Test)

Example 29 with IndexResponse

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");
}
Also used : IndexResponse(org.elasticsearch.action.index.IndexResponse) NodeTestHelper.createNode(org.elasticsearch.module.graphite.test.NodeTestHelper.createNode) Node(org.elasticsearch.node.Node) Test(org.junit.Test)

Example 30 with IndexResponse

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 ");
}
Also used : IndexResponse(org.elasticsearch.action.index.IndexResponse) Test(org.junit.Test)

Aggregations

IndexResponse (org.elasticsearch.action.index.IndexResponse)76 Test (org.junit.Test)15 SearchResponse (org.elasticsearch.action.search.SearchResponse)13 IOException (java.io.IOException)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)10 DeleteResponse (org.elasticsearch.action.delete.DeleteResponse)10 IndexRequest (org.elasticsearch.action.index.IndexRequest)10 IndexRequestBuilder (org.elasticsearch.action.index.IndexRequestBuilder)10 ElasticsearchException (org.elasticsearch.ElasticsearchException)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 ArrayList (java.util.ArrayList)5 ExecutionException (java.util.concurrent.ExecutionException)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 GetResponse (org.elasticsearch.action.get.GetResponse)4 Settings (org.elasticsearch.common.settings.Settings)4 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)3