use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project samza by apache.
the class DefaultIndexRequestFactoryTest method testGetIndexRequestMessageBytes.
@Test
public void testGetIndexRequestMessageBytes() throws Exception {
IndexRequest indexRequest = INDEX_REQUEST_FACTORY.getIndexRequest(new OutgoingMessageEnvelope(SYSTEM, "{\"foo\":\"bar\"}".getBytes(Charsets.UTF_8)));
assertEquals(Collections.singletonMap("foo", "bar"), indexRequest.sourceAsMap());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project samza by apache.
the class ElasticsearchSystemProducerTest method testSend.
@Test
public void testSend() throws Exception {
OutgoingMessageEnvelope envelope = mock(OutgoingMessageEnvelope.class);
IndexRequest indexRequest = mock(IndexRequest.class);
when(INDEX_REQUEST_FACTORY.getIndexRequest(envelope)).thenReturn(indexRequest);
producer.send(SOURCE_ONE, envelope);
verify(processorOne).add(indexRequest);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project flink by apache.
the class TestEmitter method createIndexRequest.
public IndexRequest createIndexRequest(Tuple2<Integer, String> element) {
Map<String, Object> document = new HashMap<>();
document.put(dataFieldName, element.f1);
try {
return new IndexRequest(index).id(element.f0.toString()).type(DOCUMENT_TYPE).source(xContentBuilderProvider.getBuilder().map(document));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project flink by apache.
the class RowElasticsearchEmitter method processUpsert.
private void processUpsert(RowData row, RequestIndexer indexer) {
final byte[] document = serializationSchema.serialize(row);
final String key = createKey.apply(row);
if (key != null) {
final UpdateRequest updateRequest = new UpdateRequest(indexGenerator.generate(row), documentType, key).doc(document, contentType).upsert(document, contentType);
indexer.add(updateRequest);
} else {
final IndexRequest indexRequest = new IndexRequest(indexGenerator.generate(row), documentType).id(key).source(document, contentType);
indexer.add(indexRequest);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project pinpoint by naver.
the class ElasticsearchIT_6_0_x_IT method testIndexV60UP.
private void testIndexV60UP(PluginTestVerifier verifier) throws IOException {
IndexRequest indexRequest = new IndexRequest("postv6", "doc", "3");
String jsonString = "{" + "\"user\":\"kimchy\"," + "\"postDate\":\"2013-01-30\"," + "\"message\":\"trying out Elasticsearch\"" + "}";
indexRequest.source(jsonString, XContentType.JSON);
Class<?> clazz;
try {
clazz = Class.forName("org.elasticsearch.client.RestHighLevelClient");
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
Method method;
try {
method = clazz.getMethod("index", IndexRequest.class, Class.forName("[Lorg.apache.http.Header;"));
} catch (NoSuchMethodException | ClassNotFoundException e) {
throw new AssertionError(e);
}
try {
method.invoke(restHighLevelClient, indexRequest, new Header[] {});
} catch (IllegalAccessException | InvocationTargetException e) {
throw new AssertionError(e);
}
Method index;
try {
index = restHighLevelClient.getClass().getDeclaredMethod("index", IndexRequest.class, Class.forName("[Lorg.apache.http.Header;"));
} catch (NoSuchMethodException | ClassNotFoundException e) {
throw new AssertionError(e);
}
verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, ELASTICSEARCH_ADDRESS, "ElasticSearch", new ExpectedAnnotation(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY.getName(), indexRequest.toString())));
}
Aggregations