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


Java GetResponse.getVersion方法代码示例

本文整理汇总了Java中org.elasticsearch.action.get.GetResponse.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java GetResponse.getVersion方法的具体用法?Java GetResponse.getVersion怎么用?Java GetResponse.getVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.get.GetResponse的用法示例。


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

示例1: doStore

import org.elasticsearch.action.get.GetResponse; //导入方法依赖的package包/类
private void doStore(Task parentTask, GetResponse response, CreateModelFromSetRequest request,
                     ActionListener<CreateModelFromSetResponse> listener) {
    if (!response.isExists()) {
        throw new IllegalArgumentException("Stored feature set [" + request.getFeatureSetName() + "] does not exist");
    }
    if (request.getExpectedSetVersion() != null && request.getExpectedSetVersion() != response.getVersion()) {
        throw new IllegalArgumentException("Stored feature set [" + request.getFeatureSetName() + "]" +
                " has version [" + response.getVersion() + "] but [" + request.getExpectedSetVersion() + "] was expected.");
    }
    final StoredFeatureSet set;
    try {
        set = IndexFeatureStore.parse(StoredFeatureSet.class, StoredFeatureSet.TYPE, response.getSourceAsBytesRef());
    } catch(IOException ioe) {
        throw new IllegalStateException("Cannot parse stored feature set [" + request.getFeatureSetName() + "]", ioe);
    }
    // Model will be parsed & checked by TransportFeatureStoreAction
    StoredLtrModel model = new StoredLtrModel(request.getModelName(), set, request.getDefinition());
    FeatureStoreRequest featureStoreRequest = new FeatureStoreRequest(request.getStore(), model, FeatureStoreRequest.Action.CREATE);
    featureStoreRequest.setRouting(request.getRouting());
    featureStoreRequest.setParentTask(clusterService.localNode().getId(), parentTask.getId());
    featureStoreRequest.setValidation(request.getValidation());
    featureStoreAction.execute(featureStoreRequest, ActionListener.wrap(
            (r) -> listener.onResponse(new CreateModelFromSetResponse(r.getResponse())),
            listener::onFailure));

}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:27,代码来源:TransportCreateModelFromSetAction.java

示例2: getIndex

import org.elasticsearch.action.get.GetResponse; //导入方法依赖的package包/类
/**
 * 获取索引信息
 * @param index
 * @param type
 * @param id
 */
private static void getIndex(String index, String type, String id){
	Client client = createTransportClient();
	GetResponse response = client.prepareGet(index, type, id)
	        .execute()
	        .actionGet();
	boolean exists = response.isExists();
	System.out.println(exists);// 判断索引是否存在
	String sourceString = response.getSourceAsString();
	System.out.println(sourceString);// 获取索引,并且打印出索引内容
	System.out.println("****************index ***********************");
	// Index name
	String _index = response.getIndex();
	// Type name
	String _type = response.getType();
	// Document ID (generated or not)
	String _id = response.getId();
	// Version (if it's the first time you index this document, you will get: 1)
	long _version = response.getVersion();
	System.out.println(_index+","+_type+","+_id+","+_version);
}
 
开发者ID:ameizi,项目名称:elasticsearch-jest-example,代码行数:27,代码来源:TransportClient.java

示例3: fromGetResponse

import org.elasticsearch.action.get.GetResponse; //导入方法依赖的package包/类
public static PersistentServiceDef fromGetResponse(GetResponse getResponse) {
    long persistentVersion = getResponse.getVersion();
    JsonObject document = new JsonObject(getResponse.getSourceAsString());

    return new PersistentServiceDef(getResponse.getId(), persistentVersion)
            .merge(document);
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:8,代码来源:PersistentServiceDef.java

示例4: getCourse

import org.elasticsearch.action.get.GetResponse; //导入方法依赖的package包/类
private Course getCourse(String courseId, Credentials credentials) {
	GetResponse response = Start.get().getElasticClient()//
			.get(credentials.backendId(), COURSE, courseId);

	Course course = Json7.toPojo(response.getSourceAsString(), Course.class);
	course.meta.id = response.getId();
	course.meta.type = "course";
	course.meta.version = response.getVersion();

	return course;
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:12,代码来源:CaremenResource.java

示例5: fromGetResponse

import org.elasticsearch.action.get.GetResponse; //导入方法依赖的package包/类
public static PersistentObject fromGetResponse(PersistentContainer container, GetResponse getResponse) {

        String id = getResponse.getId();
        long persistentVersion = getResponse.getVersion();
        JsonObject document = new JsonObject(getResponse.getSourceAsString());

        return new PersistentObject(container, id, persistentVersion)
                .merge(document);

    }
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:11,代码来源:PersistentObject.java


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