本文整理了Java中org.elasticsearch.client.Client.bulk()
方法的一些代码示例,展示了Client.bulk()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.bulk()
方法的具体详情如下:
包路径:org.elasticsearch.client.Client
类名称:Client
方法名:bulk
[英]Executes a bulk of index / delete operations.
[中]执行大量索引/删除操作。
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public void execute(BulkRequest bulkRequest) {
this.currentBulkRequest = bulkRequest;
client.bulk(bulkRequest, this);
}
}
代码示例来源:origin: harbby/presto-connectors
public void execute(BulkRequest bulkRequest) {
this.currentBulkRequest = bulkRequest;
client.bulk(bulkRequest, this);
}
}
代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core
@Override
public BulkResponse bulk(BulkRequest request) {
return client.bulk(request).actionGet();
}
代码示例来源:origin: org.fusesource.insight/insight-graph
public void run() {
while (running) {
try {
IndexRequest req = queue.take();
// Send data
BulkRequest bulk = new BulkRequest();
int nb = 0;
while (req != null && (nb == 0 || nb < max)) {
bulk.add(req);
nb++;
req = queue.poll();
}
if (bulk.numberOfActions() > 0) {
BulkResponse rep = node.client().bulk(bulk).actionGet();
for (BulkItemResponse bir : rep.items()) {
if (bir.failed()) {
LOGGER.warn("Error indexing item: {}", bir.getFailureMessage());
}
}
}
} catch (Exception e) {
if (running) {
LOGGER.warn("Error while sending indexes", e);
}
}
}
}
代码示例来源:origin: io.fabric8.insight/insight-elasticsearch
public void run() {
while (running) {
try {
ActionRequest req = queue.take();
// Send data
BulkRequest bulk = new BulkRequest();
int nb = 0;
while (req != null && (nb == 0 || nb < max)) {
bulk.add(req);
nb++;
req = queue.poll();
}
if (bulk.numberOfActions() > 0) {
BulkResponse rep = node.client().bulk(bulk).actionGet();
for (BulkItemResponse bir : rep.getItems()) {
if (bir.isFailed()) {
LOGGER.warn("Error executing request: {}", bir.getFailureMessage());
}
}
}
} catch (Exception e) {
if (running) {
LOGGER.warn("Error while sending requests", e);
}
}
}
}
代码示例来源:origin: mbok/logsniffer
@Override
public Object execute(final Client client) {
final BulkRequest deletes = new BulkRequest().refresh(true);
for (final String id : eventIds) {
for (final String index : indexNamingStrategy.getRetrievalNames(snifferId)) {
deletes.add(new DeleteRequest(index, getType(snifferId), id));
}
}
client.bulk(deletes).actionGet();
logger.info("Deleted events: {}", (Object[]) eventIds);
return null;
}
});
代码示例来源:origin: jprante/elasticsearch-transport-websocket
listener.afterBulk(executionId, bulkRequest, client.bulk(bulkRequest).actionGet());
} catch (Exception e) {
listener.afterBulk(executionId, bulkRequest, e);
client.bulk(bulkRequest, new ActionListener<BulkResponse>() {
@Override
public void onResponse(BulkResponse response) {
代码示例来源:origin: io.fabric8.insight/insight-elasticsearch-factory
public void run() {
while (running) {
try {
ActionRequest req = queue.take();
// Send data
BulkRequest bulk = new BulkRequest();
int nb = 0;
while (req != null && (nb == 0 || nb < max)) {
bulk.add(req);
nb++;
req = queue.poll();
}
if (bulk.numberOfActions() > 0) {
BulkResponse rep = getNode().client().bulk(bulk).actionGet();
for (BulkItemResponse bir : rep.getItems()) {
if (bir.isFailed()) {
LOGGER.warn("Error executing request: {}", bir.getFailureMessage());
}
}
}
} catch (Exception e) {
if (running) {
LOGGER.warn("Error while sending requests", e);
}
}
}
}
代码示例来源:origin: jboss-fuse/fabric8
public void run() {
while (running) {
try {
ActionRequest req = queue.take();
// Send data
BulkRequest bulk = new BulkRequest();
int nb = 0;
while (req != null && (nb == 0 || nb < max)) {
bulk.add(req);
nb++;
req = queue.poll();
}
if (bulk.numberOfActions() > 0) {
BulkResponse rep = getNode().client().bulk(bulk).actionGet();
for (BulkItemResponse bir : rep.getItems()) {
if (bir.isFailed()) {
LOGGER.warn("Error executing request: {}", bir.getFailureMessage());
}
}
}
} catch (Exception e) {
if (running) {
LOGGER.warn("Error while sending requests", e);
}
}
}
}
代码示例来源:origin: com.netflix.suro/suro-elasticsearch
@Override
public void run() {
BulkResponse response = client.bulk(request).actionGet();
if (response.hasFailures()) {
int rejectedCount = 0;
for (BulkItemResponse r : response.getItems()) {
if (r.isFailed() && !r.getFailureMessage().contains("DocumentAlreadyExistsException")) {
log.error("Failed with: " + r.getFailureMessage());
++rejectedCount;
recover(r.getItemId(), request);
}
}
rejectedRowCount += rejectedCount;
indexedRowCount += request.numberOfActions() - rejectedCount;
} else {
indexedRowCount += request.numberOfActions();
}
indexDelay = System.currentTimeMillis() - indexInfo.create((Message) request.payloads().get(0)).getTimestamp();
}
};
代码示例来源:origin: org.vertexium/vertexium-elasticsearch-singledocument
protected void doBulkRequest(BulkRequest bulkRequest) {
BulkResponse response = getClient().bulk(bulkRequest).actionGet();
if (response.hasFailures()) {
for (BulkItemResponse bulkResponse : response) {
if (bulkResponse.isFailed()) {
LOGGER.error("Failed to index %s (message: %s)", bulkResponse.getId(), bulkResponse.getFailureMessage());
}
}
throw new VertexiumException("Could not add element.");
}
}
代码示例来源:origin: org.vertexium/vertexium-elasticsearch2
protected void doBulkRequest(BulkRequest bulkRequest) {
BulkResponse response = getClient().bulk(bulkRequest).actionGet();
if (response.hasFailures()) {
for (BulkItemResponse bulkResponse : response) {
if (bulkResponse.isFailed()) {
LOGGER.error("Failed to index %s (message: %s)", bulkResponse.getId(), bulkResponse.getFailureMessage());
}
}
throw new VertexiumException("Could not add element.");
}
}
代码示例来源:origin: jloisel/elastic-crud
@Before
public void before() throws IOException {
if(!client.admin().indices().prepareExists(INDEX).execute().actionGet().isExists()) {
client.admin().indices().prepareCreate(INDEX).execute().actionGet();
}
final BulkRequestBuilder bulk = client.prepareBulk();
final JsonSerializer<Person> serializer = mapper.serializer(Person.class);
for (int i = 0; i < SIZE; i++) {
final String name = UUID.randomUUID().toString();
final IndexRequest request = new IndexRequest(INDEX, TYPE);
request.source(serializer.apply(Person.builder().id("").firstname(name).lastname(name).build()), JSON);
bulk.add(request);
}
client.bulk(bulk.request()).actionGet();
flush(INDEX);
}
代码示例来源:origin: jloisel/elastic-crud
@Before
public void before() throws IOException {
if(!client.admin().indices().prepareExists(INDEX).execute().actionGet().isExists()) {
client.admin().indices().prepareCreate(INDEX).execute().actionGet();
}
final JsonSerializer<Person> serializer = mapper.serializer(Person.class);
final BulkRequestBuilder bulk = client.prepareBulk();
for (int i = 0; i < SIZE; i++) {
final String name = UUID.randomUUID().toString();
final IndexRequest request = new IndexRequest(INDEX, TYPE);
request.source(serializer.apply(Person.builder().id("").firstname(name).lastname(name).build()), JSON);
bulk.add(request);
}
client.bulk(bulk.request()).actionGet();
flush(INDEX);
}
代码示例来源:origin: jloisel/elastic-crud
@Before
public void before() throws IOException {
final IndicesAdminClient indices = client.admin().indices();
if(!indices.prepareExists(INDEX).execute().actionGet().isExists()) {
indices.prepareCreate(INDEX).execute().actionGet();
}
final JsonSerializer<Person> serializer = mapper.serializer(Person.class);
final BulkRequestBuilder bulk = client.prepareBulk();
for (int i = 0; i < SIZE; i++) {
final String name = UUID.randomUUID().toString();
final IndexRequest request = new IndexRequest(INDEX, TYPE);
request.source(serializer.apply(Person.builder().id("").firstname(name).lastname(name).build()), JSON);
bulk.add(request);
}
client.bulk(bulk.request()).actionGet();
flush(INDEX);
}
代码示例来源:origin: org.eclipse.kapua/kapua-datastore-client-transport
esClientProvider.getClient().bulk(bulkRequest).actionGet(queryTimeout);
代码示例来源:origin: eclipse/kapua
esClientProvider.getClient().bulk(bulkRequest).actionGet(queryTimeout);
代码示例来源:origin: org.eclipse.kapua/kapua-datastore-client-transport
BulkResponse bulkResponse = esClientProvider.getClient().bulk(bulkRequest).actionGet(getQueryTimeout());
代码示例来源:origin: eclipse/kapua
BulkResponse bulkResponse = esClientProvider.getClient().bulk(bulkRequest).actionGet(getQueryTimeout());
代码示例来源:origin: org.elasticsearch.plugin/delete-by-query
client.bulk(bulkRequest, new ActionListener<BulkResponse>() {
@Override
public void onResponse(BulkResponse bulkResponse) {
内容来源于网络,如有侵权,请联系作者删除!