Search in sources :

Example 96 with IndexResponse

use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-graphite-plugin by spinscale.

the class GraphitePluginIntegrationTest method testThatFieldExclusionWorksWithPrefix.

@Test
public void testThatFieldExclusionWorksWithPrefix() throws Exception {
    String prefix = "my.awesome.prefix";
    String excludeRegex = prefix + ".node.[http|jvm].*";
    node = createNode(clusterName, GRAPHITE_SERVER_PORT, "1s", null, excludeRegex, prefix);
    IndexResponse indexResponse = indexElement(node, index, type, "value");
    assertThat(indexResponse.getId(), is(notNullValue()));
    Thread.sleep(2000);
    ensureValidKeyNames();
    // ensure no global exclusion
    assertGraphiteMetricIsContained(prefix + ".indexes." + index + ".id.0.indexing._all.indexCount 1");
    assertGraphiteMetricIsNotContained(prefix + ".node.jvm.threads.peakCount ");
    assertGraphiteMetricIsNotContained(prefix + ".node.http.totalOpen ");
}
Also used : IndexResponse(org.elasticsearch.action.index.IndexResponse) Test(org.junit.Test)

Example 97 with IndexResponse

use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-graphite-plugin by spinscale.

the class GraphitePluginIntegrationTest method testThatFieldInclusionWinsOverExclusion.

@Test
public void testThatFieldInclusionWinsOverExclusion() throws Exception {
    String excludeRegex = ".*" + clusterName + ".*";
    String includeRegex = ".*\\.peakCount";
    node = createNode(clusterName, GRAPHITE_SERVER_PORT, "1s", includeRegex, excludeRegex, null);
    IndexResponse indexResponse = indexElement(node, index, type, "value");
    assertThat(indexResponse.getId(), is(notNullValue()));
    SearchResponse searchResponse = searchElement(node);
    assertThat(searchResponse.status(), is(notNullValue()));
    Thread.sleep(2000);
    ensureValidKeyNames();
    assertGraphiteMetricIsNotContained("elasticsearch." + clusterName + ".indexes." + index + ".id.0.indexing._all.indexCount 1");
    assertGraphiteMetricIsContained("elasticsearch." + clusterName + ".node.jvm.threads.peakCount ");
}
Also used : IndexResponse(org.elasticsearch.action.index.IndexResponse) SearchResponse(org.elasticsearch.action.search.SearchResponse) Test(org.junit.Test)

Example 98 with IndexResponse

use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-graphite-plugin by spinscale.

the class GraphitePluginIntegrationTest method testThatFieldExclusionWorks.

@Test
public void testThatFieldExclusionWorks() throws Exception {
    String excludeRegex = ".*\\.peakCount";
    node = createNode(clusterName, GRAPHITE_SERVER_PORT, "1s", null, excludeRegex, null);
    IndexResponse indexResponse = indexElement(node, index, type, "value");
    assertThat(indexResponse.getId(), is(notNullValue()));
    Thread.sleep(2000);
    ensureValidKeyNames();
    // ensure no global exclusion
    assertGraphiteMetricIsContained("elasticsearch." + clusterName + ".indexes." + index + ".id.0.indexing._all.indexCount 1");
    assertGraphiteMetricIsNotContained("elasticsearch." + clusterName + ".node.jvm.threads.peakCount ");
}
Also used : IndexResponse(org.elasticsearch.action.index.IndexResponse) Test(org.junit.Test)

Example 99 with IndexResponse

use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-opennlp-plugin by spinscale.

the class OpenNlpPluginIntegrationTest method testThatOwnAnalyzersCanBeDefinedPerNlpMappedField.

@Test
public void testThatOwnAnalyzersCanBeDefinedPerNlpMappedField() throws IOException {
    putMapping("/test-mapping-analyzers.json");
    String sampleText = copyToStringFromClasspath("/sample-text.txt");
    IndexResponse indexResponse = indexElement(sampleText);
    SearchResponse nonAnalyzedFieldSearchResponse = query(QueryBuilders.termQuery("someField.name", "jack"));
    assertThat(nonAnalyzedFieldSearchResponse.getHits().totalHits(), is(1L));
    // analyzed, therefore not resulting anything like the above query
    SearchResponse analyzedFieldSearchResponse = query(QueryBuilders.termQuery("someFieldAnalyzed.name", "jack"));
    assertThat(analyzedFieldSearchResponse.getHits().totalHits(), is(0L));
    SearchResponse searchResponse = query(QueryBuilders.prefixQuery("someFieldAnalyzed.name", "Jack"));
    assertThat(searchResponse.getHits().totalHits(), is(1L));
    searchResponse = query(QueryBuilders.matchQuery("someFieldAnalyzed.name", "Jack Nicholson"));
    assertThat(searchResponse.getHits().totalHits(), is(1L));
    assertThat(searchResponse.getHits().getAt(0).id(), is(indexResponse.getId()));
}
Also used : CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) IndexResponse(org.elasticsearch.action.index.IndexResponse) SearchResponse(org.elasticsearch.action.search.SearchResponse) Test(org.junit.Test)

Example 100 with IndexResponse

use of org.elasticsearch.action.index.IndexResponse in project elasticsearch-opennlp-plugin by spinscale.

the class OpenNlpPluginIntegrationTest method indexElement.

private IndexResponse indexElement(String value) {
    IndexResponse indexResponse = node.client().prepareIndex(index, type).setSource("someFieldAnalyzed", value, "someField", value).setRefresh(true).execute().actionGet();
    assertThat(indexResponse.getId(), is(notNullValue()));
    return indexResponse;
}
Also used : CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) IndexResponse(org.elasticsearch.action.index.IndexResponse)

Aggregations

IndexResponse (org.elasticsearch.action.index.IndexResponse)103 Test (org.junit.Test)26 SearchResponse (org.elasticsearch.action.search.SearchResponse)18 IOException (java.io.IOException)15 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)15 HashMap (java.util.HashMap)13 DeleteResponse (org.elasticsearch.action.delete.DeleteResponse)13 IndexRequest (org.elasticsearch.action.index.IndexRequest)13 ElasticsearchException (org.elasticsearch.ElasticsearchException)11 CountDownLatch (java.util.concurrent.CountDownLatch)10 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)8 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)7 Settings (org.elasticsearch.common.settings.Settings)7 ArrayList (java.util.ArrayList)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 DeleteIndexResponse (org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse)6 ExecutionException (java.util.concurrent.ExecutionException)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 BulkItemResponse (org.elasticsearch.action.bulk.BulkItemResponse)5