本文整理匯總了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));
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}