本文整理匯總了Java中org.elasticsearch.action.delete.DeleteRequest.parent方法的典型用法代碼示例。如果您正苦於以下問題:Java DeleteRequest.parent方法的具體用法?Java DeleteRequest.parent怎麽用?Java DeleteRequest.parent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.action.delete.DeleteRequest
的用法示例。
在下文中一共展示了DeleteRequest.parent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
示例3: 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);
}
});
}
示例4: 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);
}
}
示例5: 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);
}