use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexResponse in project tutorials by eugenp.
the class GeoQueriesTest method givenGeoPointData_whenExecutedGeoBoundingBoxQuery_thenResultNonEmpty.
@Test
public void givenGeoPointData_whenExecutedGeoBoundingBoxQuery_thenResultNonEmpty() {
String jsonObject = "{\"name\":\"Pyramids of Giza\",\"location\":[31.131302,29.976480]}";
IndexResponse response = client.prepareIndex(WONDERS_OF_WORLD, WONDERS).setSource(jsonObject).get();
String pyramidsOfGizaId = response.getId();
client.admin().indices().prepareRefresh(WONDERS_OF_WORLD).get();
QueryBuilder qb = QueryBuilders.geoBoundingBoxQuery("location").bottomLeft(28, 30).topRight(31, 32);
SearchResponse searchResponse = client.prepareSearch(WONDERS_OF_WORLD).setTypes(WONDERS).setQuery(qb).execute().actionGet();
List<String> ids = Arrays.stream(searchResponse.getHits().getHits()).map(SearchHit::getId).collect(Collectors.toList());
assertTrue(ids.contains(pyramidsOfGizaId));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexResponse in project arctic-sea by 52North.
the class ElasticsearchAdminHandlerIT method connectTransportMode.
@Test
public void connectTransportMode() throws InterruptedException {
settings.setNodeConnectionMode(ElasticsearchSettingsKeys.CONNECTION_MODE_TRANSPORT_CLIENT);
adminHandler.init();
Map<String, Object> data = new HashMap<>();
data.put("test", "test-string");
IndexResponse idx = dataHandler.persist(data);
Thread.sleep(2000);
String ret = getEmbeddedClient().prepareGet(idx.getIndex(), idx.getType(), idx.getId()).get().getSourceAsString();
Assert.assertNotNull(ret);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexResponse in project arctic-sea by 52North.
the class ElasticsearchAdminHandlerIT method connectNodeMode.
@Test
public void connectNodeMode() throws Exception {
settings.setNodeConnectionMode(ElasticsearchSettingsKeys.CONNECTION_MODE_NODE);
adminHandler.init();
Map<String, Object> data = new HashMap<>();
data.put("test", "test-string");
IndexResponse idx = dataHandler.persist(data);
Thread.sleep(2000);
String ret = getEmbeddedClient().prepareGet(idx.getIndex(), idx.getType(), idx.getId()).get().getSourceAsString();
Assert.assertNotNull(ret);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexResponse in project tutorials-java by Artister.
the class BookController method add.
@PostMapping("add/book/novel")
@ResponseBody
public ResponseEntity add(@RequestParam(name = "title") @NotBlank(message = "标题不可以为空") String title, @RequestParam(name = "author") @NotBlank(message = "作者不可以为空") String author, @RequestParam(name = "word_count") @NotBlank(message = "字数不可以为空") String wordCount, @RequestParam(name = "publish_date") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date publishDate) {
try {
XContentBuilder content = XContentFactory.jsonBuilder().startObject().field("title", title).field("author", author).field("word_count", wordCount).field("publish_date", publishDate).endObject();
IndexResponse response = client.prepareIndex("book", "novel").setSource(content).get();
return new ResponseEntity(response.getId(), HttpStatus.OK);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
use of org.graylog.shaded.elasticsearch7.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 ");
}
Aggregations