use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project beam by apache.
the class HadoopFormatIOElasticIT method prepareElasticIndex.
private static void prepareElasticIndex() throws IOException {
RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(options.getElasticServerIp(), options.getElasticServerPort(), "http")));
for (int i = 0; i < 1000; i++) {
IndexRequest request = new IndexRequest(ELASTIC_INDEX_NAME).source(createElasticRow(i));
client.index(request, RequestOptions.DEFAULT);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project beam by apache.
the class HadoopFormatIOElasticTest method prepareElasticIndex.
private static void prepareElasticIndex() throws IOException {
RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(elasticsearch.getContainerIpAddress(), elasticsearch.getMappedPort(9200), "http")));
for (int i = 0; i < TEST_DATA_ROW_COUNT; i++) {
IndexRequest request = new IndexRequest(ELASTIC_INDEX_NAME).source(createElasticRow(ELASTIC_TYPE_ID_PREFIX + i, "Faraday" + i));
client.index(request, RequestOptions.DEFAULT);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project hazelcast by hazelcast.
the class AuthElasticSinksTest method given_clientWithWrongPassword_whenWriteToElasticSink_thenFailWithAuthenticationException.
@Test
public void given_clientWithWrongPassword_whenWriteToElasticSink_thenFailWithAuthenticationException() {
ElasticsearchContainer container = ElasticSupport.secureElastic.get();
String containerIp = container.getContainerIpAddress();
Integer port = container.getMappedPort(PORT);
Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(() -> client("elastic", "WrongPassword", containerIp, port)).bulkRequestFn(() -> new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE)).mapToRequestFn((TestItem item) -> new IndexRequest("my-index").source(item.asMap())).retries(0).build();
Pipeline p = Pipeline.create();
p.readFrom(TestSources.items(new TestItem("id", "Frantisek"))).writeTo(elasticSink);
assertThatThrownBy(() -> submitJob(p)).hasRootCauseInstanceOf(ElasticsearchStatusException.class).hasStackTraceContaining("unable to authenticate user [elastic]");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project hazelcast by hazelcast.
the class AuthElasticSinksTest method given_authenticatedClient_whenWriteToElasticSink_thenFinishSuccessfully.
@Test
public void given_authenticatedClient_whenWriteToElasticSink_thenFinishSuccessfully() throws IOException {
Sink<TestItem> elasticSink = new ElasticSinkBuilder<>().clientFn(elasticClientSupplier()).bulkRequestFn(() -> new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE)).mapToRequestFn((TestItem item) -> new IndexRequest("my-index").source(item.asMap())).build();
Pipeline p = Pipeline.create();
p.readFrom(TestSources.items(new TestItem("id", "Frantisek"))).writeTo(elasticSink);
submitJob(p);
assertSingleDocument();
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest in project elasticsearch-jdbc by jprante.
the class StandardSink method index.
@Override
public void index(IndexableObject object, boolean create) throws IOException {
if (clientAPI == null) {
return;
}
if (Strings.hasLength(object.index())) {
setIndex(object.index());
}
if (Strings.hasLength(object.type())) {
setType(object.type());
}
if (Strings.hasLength(object.id())) {
setId(object.id());
}
IndexRequest request = Requests.indexRequest(this.index).type(this.type).id(getId()).source(object.build());
if (object.meta(ControlKeys._version.name()) != null) {
request.versionType(VersionType.EXTERNAL).version(Long.parseLong(object.meta(ControlKeys._version.name())));
}
if (object.meta(ControlKeys._routing.name()) != null) {
request.routing(object.meta(ControlKeys._routing.name()));
}
if (object.meta(ControlKeys._parent.name()) != null) {
request.parent(object.meta(ControlKeys._parent.name()));
}
if (object.meta(ControlKeys._timestamp.name()) != null) {
request.timestamp(object.meta(ControlKeys._timestamp.name()));
}
if (object.meta(ControlKeys._ttl.name()) != null) {
request.ttl(Long.parseLong(object.meta(ControlKeys._ttl.name())));
}
if (logger.isTraceEnabled()) {
logger.trace("adding bulk index action {}", request.source().toUtf8());
}
clientAPI.bulkIndex(request);
}
Aggregations