org.elasticsearch.action.deletebyquery.DeleteByQueryRequest Java Examples

The following examples show how to use org.elasticsearch.action.deletebyquery.DeleteByQueryRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeleteByQueryRequestBuilder.java    From elasticshell with Apache License 2.0 6 votes vote down vote up
@Override
protected XContentBuilder toXContent(DeleteByQueryRequest request, DeleteByQueryResponse response, XContentBuilder builder) throws IOException {
    builder.startObject().field(Fields.OK, true);
    builder.startObject("_indices");
    for (IndexDeleteByQueryResponse indexDeleteByQueryResponse : response.getIndices().values()) {
        builder.startObject(indexDeleteByQueryResponse.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
        builder.startObject("_shards");
        builder.field("total", indexDeleteByQueryResponse.getTotalShards());
        builder.field("successful", indexDeleteByQueryResponse.getSuccessfulShards());
        builder.field("failed", indexDeleteByQueryResponse.getFailedShards());
        builder.endObject();
        builder.endObject();
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
Example #2
Source File: ElasticOperationWorker.java    From elasticsearch-river-neo4j with Apache License 2.0 5 votes vote down vote up
@Override
public void run(Client client) {
    try {
        DeleteByQueryRequest req = strategy.build(index, type, version);
        client.deleteByQuery(req).actionGet();
    } catch (RuntimeException e) {
        logger.error("Error expunging [{}]", e);
    }
}
 
Example #3
Source File: SimpleDeletingStrategyTest.java    From elasticsearch-river-neo4j with Apache License 2.0 5 votes vote down vote up
@Test
public void thatNodePropertiesAreUsedAsFieldValues() throws IOException {
    long id = new Random().nextInt(50000) + 1;
    DeleteByQueryRequest req = s.build("neo4j-index", "node", 12);
    assertEquals("neo4j-index", req.indices()[0]);
    assertEquals("[[neo4j-index]][[node]], source[{\"query\":{\"range\":{\"version\":{\"from\":null,\"to\":11," +
            "\"include_lower\":true,\"include_upper\":true}}}}]", req.toString());
}
 
Example #4
Source File: SimpleDeletingStrategy.java    From elasticsearch-river-neo4j with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteByQueryRequest build(String index, String type, long currentVersion) {
    QuerySourceBuilder querySourceBuilder = new QuerySourceBuilder().setQuery(QueryBuilders.rangeQuery("version").to(currentVersion - 1));
    return new DeleteByQueryRequest(index).types(type).source(querySourceBuilder);
}
 
Example #5
Source File: DeleteByQueryRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
public DeleteByQueryRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
    super(client, new DeleteByQueryRequest(), jsonToString, stringToJson);
}
 
Example #6
Source File: DeleteByQueryRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<DeleteByQueryResponse> doExecute(DeleteByQueryRequest request) {
    return client.deleteByQuery(request);
}
 
Example #7
Source File: DeletingStategy.java    From elasticsearch-river-neo4j with Apache License 2.0 votes vote down vote up
DeleteByQueryRequest build(String index, String type, long currentVersion);