本文整理汇总了Java中org.elasticsearch.action.delete.DeleteRequest.routing方法的典型用法代码示例。如果您正苦于以下问题:Java DeleteRequest.routing方法的具体用法?Java DeleteRequest.routing怎么用?Java DeleteRequest.routing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.delete.DeleteRequest
的用法示例。
在下文中一共展示了DeleteRequest.routing方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: 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);
}
示例3: testDelete
import org.elasticsearch.action.delete.DeleteRequest; //导入方法依赖的package包/类
public void testDelete() throws IOException {
String index = randomAsciiOfLengthBetween(3, 10);
String type = randomAsciiOfLengthBetween(3, 10);
String id = randomAsciiOfLengthBetween(3, 10);
DeleteRequest deleteRequest = new DeleteRequest(index, type, id);
Map<String, String> expectedParams = new HashMap<>();
setRandomTimeout(deleteRequest, expectedParams);
setRandomRefreshPolicy(deleteRequest, expectedParams);
setRandomVersion(deleteRequest, expectedParams);
setRandomVersionType(deleteRequest, expectedParams);
if (frequently()) {
if (randomBoolean()) {
String routing = randomAsciiOfLengthBetween(3, 10);
deleteRequest.routing(routing);
expectedParams.put("routing", routing);
}
if (randomBoolean()) {
String parent = randomAsciiOfLengthBetween(3, 10);
deleteRequest.parent(parent);
expectedParams.put("parent", parent);
}
}
Request request = Request.delete(deleteRequest);
assertEquals("/" + index + "/" + type + "/" + id, request.endpoint);
assertEquals(expectedParams, request.params);
assertEquals("DELETE", request.method);
assertNull(request.entity);
}
示例4: handleRequest
import org.elasticsearch.action.delete.DeleteRequest; //导入方法依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
deleteRequest.routing(request.param("routing"));
deleteRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing
deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
deleteRequest.refresh(request.paramAsBoolean("refresh", deleteRequest.refresh()));
deleteRequest.version(RestActions.parseVersion(request));
deleteRequest.versionType(VersionType.fromString(request.param("version_type"), deleteRequest.versionType()));
String consistencyLevel = request.param("consistency");
if (consistencyLevel != null) {
deleteRequest.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
}
client.delete(deleteRequest, new RestBuilderListener<DeleteResponse>(channel) {
@Override
public RestResponse buildResponse(DeleteResponse result, XContentBuilder builder) throws Exception {
ActionWriteResponse.ShardInfo shardInfo = result.getShardInfo();
builder.startObject().field(Fields.FOUND, result.isFound())
.field(Fields._INDEX, result.getIndex())
.field(Fields._TYPE, result.getType())
.field(Fields._ID, result.getId())
.field(Fields._VERSION, result.getVersion())
.value(shardInfo)
.endObject();
RestStatus status = shardInfo.status();
if (!result.isFound()) {
status = NOT_FOUND;
}
return new BytesRestResponse(status, builder);
}
});
}
示例5: delete
import org.elasticsearch.action.delete.DeleteRequest; //导入方法依赖的package包/类
@Override
public void delete(IndexableObject object) {
if (Strings.hasLength(object.index())) {
this.index = object.index();
}
if (Strings.hasLength(object.type())) {
this.type = object.type();
}
if (Strings.hasLength(object.id())) {
setId(object.id());
}
if (getId() == null) {
return; // skip if no doc is specified to delete
}
DeleteRequest request = Requests.deleteRequest(this.index).type(this.type).id(getId());
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 (logger.isTraceEnabled()) {
logger.trace("adding bulk delete action {}/{}/{}", request.index(), request.type(), request.id());
}
if (ingest != null) {
ingest.bulkDelete(request);
}
}
示例6: delete
import org.elasticsearch.action.delete.DeleteRequest; //导入方法依赖的package包/类
@Override
public void delete(StructuredObject object) {
if (!checkStatus()) {
return;
}
if (Strings.hasLength(object.index())) {
indexTemplate(object.index());
}
if (Strings.hasLength(object.type())) {
type(object.type());
}
if (Strings.hasLength(object.id())) {
id(object.id());
}
if (id == null) {
return; // skip if no doc is specified to delete
}
DeleteRequest request = Requests.deleteRequest(index()).type(type()).id(id());
if (object.meta(StructuredObject.ROUTING) != null) {
request.routing(object.meta(StructuredObject.ROUTING));
}
if (object.meta(StructuredObject.PARENT) != null) {
request.parent(object.meta(StructuredObject.PARENT));
}
if (object.meta(StructuredObject.VERSION) != null && versioning) {
request.versionType(VersionType.EXTERNAL)
.version(Long.parseLong(object.meta(StructuredObject.VERSION)));
}
bulk.add(request);
}
示例7: createHttpRequest
import org.elasticsearch.action.delete.DeleteRequest; //导入方法依赖的package包/类
@Override
protected HttpRequest createHttpRequest(URL base, BulkRequest request) {
StringBuilder bulkContent = new StringBuilder();
for (ActionRequest<?> actionRequest : request.requests()) {
if (actionRequest instanceof IndexRequest) {
IndexRequest indexRequest = (IndexRequest) actionRequest;
bulkContent.append("{\"").append(indexRequest.opType().lowercase()).append("\":{");
bulkContent.append("\"_index\":\"").append(indexRequest.index()).append("\"");
bulkContent.append(",\"_type\":\"").append(indexRequest.type()).append("\"");
if (indexRequest.id() != null) {
bulkContent.append(",\"_id\":\"").append(indexRequest.id()).append("\"");
}
if (indexRequest.routing() != null) {
bulkContent.append(",\"_routing\":\"").append(indexRequest.routing()).append("\"");
}
if (indexRequest.parent() != null) {
bulkContent.append(",\"_parent\":\"").append(indexRequest.parent()).append("\"");
}
if (indexRequest.timestamp() != null) {
bulkContent.append(",\"_timestamp\":\"").append(indexRequest.timestamp()).append("\"");
}
// avoid _ttl <= 0 at all cost! It will run but not for good.
if (indexRequest.ttl() != null && indexRequest.ttl().seconds() > 0) {
bulkContent.append(",\"_ttl\":\"").append(indexRequest.ttl()).append("\"");
}
if (indexRequest.version() > 0) {
bulkContent.append(",\"_version\":\"").append(indexRequest.version()).append("\"");
if (indexRequest.versionType() != null) {
bulkContent.append(",\"_version_type\":\"").append(indexRequest.versionType().name()).append("\"");
}
}
bulkContent.append("}}\n");
bulkContent.append(indexRequest.source().toUtf8());
bulkContent.append("\n");
} else if (actionRequest instanceof DeleteRequest) {
DeleteRequest deleteRequest = (DeleteRequest) actionRequest;
bulkContent.append("{\"delete\":{");
bulkContent.append("\"_index\":\"").append(deleteRequest.index()).append("\"");
bulkContent.append(",\"_type\":\"").append(deleteRequest.type()).append("\"");
bulkContent.append(",\"_id\":\"").append(deleteRequest.id()).append("\"");
if (deleteRequest.routing() != null) {
bulkContent.append(",\"_routing\":\"").append(deleteRequest.routing()).append("\""); // _routing
}
bulkContent.append("}}\n");
}
}
return newPostRequest(base, "/_bulk", bulkContent);
}
示例8: createHttpRequest
import org.elasticsearch.action.delete.DeleteRequest; //导入方法依赖的package包/类
@Override
protected HttpRequest createHttpRequest(URL base, BulkRequest request) {
StringBuilder bulkContent = new StringBuilder();
for (ActionRequest actionRequest : request.requests()) {
if (actionRequest instanceof IndexRequest) {
IndexRequest indexRequest = (IndexRequest) actionRequest;
bulkContent.append("{\"").append(indexRequest.opType().lowercase()).append("\":{");
bulkContent.append("\"_index\":\"").append(indexRequest.index()).append("\"");
bulkContent.append(",\"_type\":\"").append(indexRequest.type()).append("\"");
if (indexRequest.id() != null) {
bulkContent.append(",\"_id\":\"").append(indexRequest.id()).append("\"");
}
if (indexRequest.routing() != null) {
bulkContent.append(",\"_routing\":\"").append(indexRequest.routing()).append("\""); // _routing
}
if (indexRequest.parent() != null) {
bulkContent.append(",\"_parent\":\"").append(indexRequest.parent()).append("\"");
}
if (indexRequest.timestamp() != null) {
bulkContent.append(",\"_timestamp\":\"").append(indexRequest.timestamp()).append("\"");
}
// avoid _ttl <= 0 at all cost!
if (indexRequest.ttl() != null && indexRequest.ttl().seconds() > 0) {
bulkContent.append(",\"_ttl\":\"").append(indexRequest.ttl()).append("\"");
}
if (indexRequest.version() > 0) {
bulkContent.append(",\"_version\":\"").append(indexRequest.version()).append("\"");
if (indexRequest.versionType() != null) {
bulkContent.append(",\"_version_type\":\"").append(indexRequest.versionType().name()).append("\"");
}
}
bulkContent.append("}}\n");
bulkContent.append(indexRequest.source().toUtf8());
bulkContent.append("\n");
} else if (actionRequest instanceof DeleteRequest) {
DeleteRequest deleteRequest = (DeleteRequest) actionRequest;
bulkContent.append("{\"delete\":{");
bulkContent.append("\"_index\":\"").append(deleteRequest.index()).append("\"");
bulkContent.append(",\"_type\":\"").append(deleteRequest.type()).append("\"");
bulkContent.append(",\"_id\":\"").append(deleteRequest.id()).append("\"");
if (deleteRequest.routing() != null) {
bulkContent.append(",\"_routing\":\"").append(deleteRequest.routing()).append("\""); // _routing
}
bulkContent.append("}}\n");
}
}
return newPostRequest(base, "/_bulk", bulkContent);
}