当前位置: 首页>>代码示例>>Java>>正文


Java DeleteRequest类代码示例

本文整理汇总了Java中org.elasticsearch.action.delete.DeleteRequest的典型用法代码示例。如果您正苦于以下问题:Java DeleteRequest类的具体用法?Java DeleteRequest怎么用?Java DeleteRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeleteRequest类属于org.elasticsearch.action.delete包,在下文中一共展示了DeleteRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
static Request delete(DeleteRequest deleteRequest) {
    String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id());

    Params parameters = Params.builder();
    parameters.withRouting(deleteRequest.routing());
    parameters.withParent(deleteRequest.parent());
    parameters.withTimeout(deleteRequest.timeout());
    parameters.withVersion(deleteRequest.version());
    parameters.withVersionType(deleteRequest.versionType());
    parameters.withRefreshPolicy(deleteRequest.getRefreshPolicy());
    parameters.withWaitForActiveShards(deleteRequest.waitForActiveShards());

    return new Request(HttpDelete.METHOD_NAME, endpoint, parameters.getParams(), null);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:Request.java

示例2: prepareRequest

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
    deleteRequest.routing(request.param("routing"));
    deleteRequest.parent(request.param("parent"));
    deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
    deleteRequest.setRefreshPolicy(request.param("refresh"));
    deleteRequest.version(RestActions.parseVersion(request));
    deleteRequest.versionType(VersionType.fromString(request.param("version_type"), deleteRequest.versionType()));

    String waitForActiveShards = request.param("wait_for_active_shards");
    if (waitForActiveShards != null) {
        deleteRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
    }

    return channel -> client.delete(deleteRequest, new RestStatusToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestDeleteAction.java

示例3: scriptChangedOpType

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
protected RequestWrapper<?> scriptChangedOpType(RequestWrapper<?> request, OpType oldOpType, OpType newOpType) {
    switch (newOpType) {
    case NOOP:
        task.countNoop();
        return null;
    case DELETE:
        RequestWrapper<DeleteRequest> delete = wrap(new DeleteRequest(request.getIndex(), request.getType(), request.getId()));
        delete.setVersion(request.getVersion());
        delete.setVersionType(VersionType.INTERNAL);
        delete.setParent(request.getParent());
        delete.setRouting(request.getRouting());
        return delete;
    default:
        throw new IllegalArgumentException("Unsupported operation type change from [" + oldOpType + "] to [" + newOpType + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AbstractAsyncBulkByScrollAction.java

示例4: testBulkRequestWithRefresh

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public void testBulkRequestWithRefresh() throws Exception {
    BulkRequest bulkRequest = new BulkRequest();
    // We force here a "id is missing" validation error
    bulkRequest.add(new DeleteRequest("index", "type", null).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
    // We force here a "type is missing" validation error
    bulkRequest.add(new DeleteRequest("index", null, "id"));
    bulkRequest.add(new DeleteRequest("index", "type", "id").setRefreshPolicy(RefreshPolicy.IMMEDIATE));
    bulkRequest.add(new UpdateRequest("index", "type", "id").doc("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
    bulkRequest.add(new IndexRequest("index", "type", "id").source("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
    ActionRequestValidationException validate = bulkRequest.validate();
    assertThat(validate, notNullValue());
    assertThat(validate.validationErrors(), not(empty()));
    assertThat(validate.validationErrors(), contains(
            "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.",
            "id is missing",
            "type is missing",
            "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.",
            "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.",
            "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead."));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:BulkRequestTests.java

示例5: testThatMissingIndexDoesNotAbortFullBulkRequest

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public void testThatMissingIndexDoesNotAbortFullBulkRequest() throws Exception{
    createIndex("bulkindex1", "bulkindex2");
    BulkRequest bulkRequest = new BulkRequest();
    bulkRequest.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
               .add(new IndexRequest("bulkindex2", "index2_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
               .add(new IndexRequest("bulkindex2", "index2_type").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
               .add(new UpdateRequest("bulkindex2", "index2_type", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
               .add(new DeleteRequest("bulkindex2", "index2_type", "3"))
               .setRefreshPolicy(RefreshPolicy.IMMEDIATE);

    client().bulk(bulkRequest).get();
    SearchResponse searchResponse = client().prepareSearch("bulkindex*").get();
    assertHitCount(searchResponse, 3);

    assertAcked(client().admin().indices().prepareClose("bulkindex2"));

    BulkResponse bulkResponse = client().bulk(bulkRequest).get();
    assertThat(bulkResponse.hasFailures(), is(true));
    assertThat(bulkResponse.getItems().length, is(5));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:BulkWithUpdatesIT.java

示例6: testFailedRequestsOnClosedIndex

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public void testFailedRequestsOnClosedIndex() throws Exception {
    createIndex("bulkindex1");

    client().prepareIndex("bulkindex1", "index1_type", "1").setSource("text", "test").get();
    assertAcked(client().admin().indices().prepareClose("bulkindex1"));

    BulkRequest bulkRequest = new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE);
    bulkRequest.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
            .add(new UpdateRequest("bulkindex1", "index1_type", "1").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
            .add(new DeleteRequest("bulkindex1", "index1_type", "1"));

    BulkResponse bulkResponse = client().bulk(bulkRequest).get();
    assertThat(bulkResponse.hasFailures(), is(true));
    BulkItemResponse[] responseItems = bulkResponse.getItems();
    assertThat(responseItems.length, is(3));
    assertThat(responseItems[0].getOpType(), is(OpType.INDEX));
    assertThat(responseItems[1].getOpType(), is(OpType.UPDATE));
    assertThat(responseItems[2].getOpType(), is(OpType.DELETE));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:BulkWithUpdatesIT.java

示例7: bulkDelete

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public String bulkDelete(String index,String type,String... ids){
	try {
		if(xclient==null){
			init();
		}
		BulkRequest request = new BulkRequest();
		for (String id : ids) {
			request.add(new DeleteRequest(index, type, id));
		}
		BulkResponse result = xclient.bulk(request);
		return result.toString();
	}catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:dev-share,项目名称:css-elasticsearch,代码行数:18,代码来源:ElasticsearchHighRestFactory.java

示例8: getClassType

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public static <Request extends ActionRequest> short getClassType(final Request request) {
    if (DeleteRequest.class.isInstance(request)) {
        return RequestUtils.TYPE_DELETE;
    } else if (DeleteByQueryRequest.class.isInstance(request)) {
        return RequestUtils.TYPE_DELETE_BY_QUERY;
    } else if (IndexRequest.class.isInstance(request)) {
        return RequestUtils.TYPE_INDEX;
    } else if (UpdateRequest.class.isInstance(request)) {
        return RequestUtils.TYPE_UPDATE;
    } else if (UpdateByQueryRequest.class.isInstance(request)) {
        return RequestUtils.TYPE_UPDATE_BY_QUERY;
    } else if (BulkRequest.class.isInstance(request)) {
        return RequestUtils.TYPE_BULK;
    }
    return 0;
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:17,代码来源:RequestUtils.java

示例9: newRequest

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <Request extends ActionRequest> Request newRequest(final short classType) {
    switch (classType) {
    case RequestUtils.TYPE_DELETE:
        return (Request) new DeleteRequest();
    case RequestUtils.TYPE_DELETE_BY_QUERY:
        return (Request) new DeleteByQueryRequest();
    case RequestUtils.TYPE_INDEX:
        return (Request) new IndexRequest();
    case RequestUtils.TYPE_UPDATE:
        return (Request) new UpdateRequest();
    case RequestUtils.TYPE_UPDATE_BY_QUERY:
        return (Request) new UpdateByQueryRequest();
    case RequestUtils.TYPE_BULK:
        return (Request) new BulkRequest();
    default:
        throw new ElasticsearchException("Unknown request type: " + classType);
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:20,代码来源:RequestUtils.java

示例10: createBulkRequest

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public static BulkRequestBuilder createBulkRequest(final Client client, final StreamInput streamInput, final String index)
        throws IOException {
    final BulkRequestBuilder builder = client.prepareBulk();
    final BulkRequest request = builder.request();
    request.readFrom(streamInput);
    if (index != null) {
        request.requests().stream().forEach(req -> {
            if (req instanceof DeleteRequest) {
                ((DeleteRequest) req).index(index);
            } else if (req instanceof DeleteByQueryRequest) {
                ((DeleteByQueryRequest) req).indices(index);
            } else if (req instanceof IndexRequest) {
                ((IndexRequest) req).index(index);
            } else if (req instanceof UpdateRequest) {
                ((UpdateRequest) req).index(index);
            } else if (req instanceof UpdateByQueryRequest) {
                ((UpdateByQueryRequest) req).indices(index);
            } else {
                throw new ElasticsearchException("Unsupported request in bulk: " + req);
            }
        });
    }
    return builder;
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:25,代码来源:RequestUtils.java

示例11: ESDeleteTask

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public ESDeleteTask(UUID jobId,
                    ESDeleteNode node,
                    TransportDeleteAction transport,
                    JobContextService jobContextService) {
    super(jobId, node.executionPhaseId(), node.docKeys().size(), jobContextService);
    List<DeleteRequest> requests = new ArrayList<>(node.docKeys().size());
    List<ActionListener> listeners = new ArrayList<>(node.docKeys().size());
    for (DocKeys.DocKey docKey : node.docKeys()) {
        DeleteRequest request = new DeleteRequest(
                ESGetTask.indexName(node.tableInfo(), docKey.partitionValues()),
                Constants.DEFAULT_MAPPING_TYPE, docKey.id());
        request.routing(docKey.routing());
        if (docKey.version().isPresent()) {
            request.version(docKey.version().get());
        }
        requests.add(request);
        SettableFuture<TaskResult> result = SettableFuture.create();
        results.add(result);
        listeners.add(new DeleteResponseListener(result));
    }

    createContext("delete", requests, listeners, transport, null);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:ESDeleteTask.java

示例12: purgeShards

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
private void purgeShards(List<IndexShard> shardsToPurge) {
    for (IndexShard shardToPurge : shardsToPurge) {
        Query query = shardToPurge.indexService().mapperService().smartNameFieldType(TTLFieldMapper.NAME).rangeQuery(null, System.currentTimeMillis(), false, true);
        Engine.Searcher searcher = shardToPurge.acquireSearcher("indices_ttl");
        try {
            logger.debug("[{}][{}] purging shard", shardToPurge.routingEntry().index(), shardToPurge.routingEntry().id());
            ExpiredDocsCollector expiredDocsCollector = new ExpiredDocsCollector();
            searcher.searcher().search(query, expiredDocsCollector);
            List<DocToPurge> docsToPurge = expiredDocsCollector.getDocsToPurge();

            BulkRequest bulkRequest = new BulkRequest();
            for (DocToPurge docToPurge : docsToPurge) {

                bulkRequest.add(new DeleteRequest().index(shardToPurge.routingEntry().index()).type(docToPurge.type).id(docToPurge.id).version(docToPurge.version).routing(docToPurge.routing));
                bulkRequest = processBulkIfNeeded(bulkRequest, false);
            }
            processBulkIfNeeded(bulkRequest, true);
        } catch (Exception e) {
            logger.warn("failed to purge", e);
        } finally {
            searcher.close();
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:IndicesTTLService.java

示例13: writeTo

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeByte(consistencyLevel.id());
    out.writeVInt(requests.size());
    for (ActionRequest request : requests) {
        if (request instanceof IndexRequest) {
            out.writeByte((byte) 0);
        } else if (request instanceof DeleteRequest) {
            out.writeByte((byte) 1);
        } else if (request instanceof UpdateRequest) {
            out.writeByte((byte) 2);
        }
        request.writeTo(out);
    }
    out.writeBoolean(refresh);
    timeout.writeTo(out);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:BulkRequest.java

示例14: setResponseFailureIfIndexMatches

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> responses, int idx, ActionRequest request, String index, Throwable e) {
    if (request instanceof IndexRequest) {
        IndexRequest indexRequest = (IndexRequest) request;
        if (index.equals(indexRequest.index())) {
            responses.set(idx, new BulkItemResponse(idx, "index", new BulkItemResponse.Failure(indexRequest.index(), indexRequest.type(), indexRequest.id(), e)));
            return true;
        }
    } else if (request instanceof DeleteRequest) {
        DeleteRequest deleteRequest = (DeleteRequest) request;
        if (index.equals(deleteRequest.index())) {
            responses.set(idx, new BulkItemResponse(idx, "delete", new BulkItemResponse.Failure(deleteRequest.index(), deleteRequest.type(), deleteRequest.id(), e)));
            return true;
        }
    } else if (request instanceof UpdateRequest) {
        UpdateRequest updateRequest = (UpdateRequest) request;
        if (index.equals(updateRequest.index())) {
            responses.set(idx, new BulkItemResponse(idx, "update", new BulkItemResponse.Failure(updateRequest.index(), updateRequest.type(), updateRequest.id(), e)));
            return true;
        }
    } else {
        throw new ElasticsearchException("Parsed unknown request in bulk actions: " + request.getClass().getSimpleName());
    }
    return false;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:TransportBulkAction.java

示例15: deleteAllByQuery

import org.elasticsearch.action.delete.DeleteRequest; //导入依赖的package包/类
public void deleteAllByQuery(String index, String type, QueryBuilder query) {
  createBulkProcessor();
  SearchResponse scrollResp = getClient().prepareSearch(index).setSearchType(SearchType.QUERY_AND_FETCH).setTypes(type).setScroll(new TimeValue(60000)).setQuery(query).setSize(10000).execute()
      .actionGet();

  while (true) {
    for (SearchHit hit : scrollResp.getHits().getHits()) {
      DeleteRequest deleteRequest = new DeleteRequest(index, type, hit.getId());
      getBulkProcessor().add(deleteRequest);
    }

    scrollResp = getClient().prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
    if (scrollResp.getHits().getHits().length == 0) {
      break;
    }

  }
  destroyBulkProcessor();
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:20,代码来源:ESDriver.java


注:本文中的org.elasticsearch.action.delete.DeleteRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。