本文整理汇总了Java中org.elasticsearch.action.update.UpdateResponse.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateResponse.getVersion方法的具体用法?Java UpdateResponse.getVersion怎么用?Java UpdateResponse.getVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.update.UpdateResponse
的用法示例。
在下文中一共展示了UpdateResponse.getVersion方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateIndexByDoc
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
/**
* 更新索引
* @param index
* @param type
* @param id
*/
private static void updateIndexByDoc(String index, String type, String id) throws Exception{
Client client = createTransportClient();
UpdateResponse response = client.prepareUpdate(index, type, id)
.setDoc(jsonBuilder()
.startObject()
.field("name", "Hadoop权威指南(第3版 修订版)")
.field("author", "Tom White")
.field("pubinfo", "清华大学出版社")
.field("pubtime", "2015-01-01")
.field("desc", "《Hadoop权威指南(第3版 修订版)》通过丰富的案例学习来解释Hadoop的幕后机理,阐述了Hadoop如何解决现实生活中的具体问题。第3版覆盖Hadoop的最新动态,包括新增的MapReduceAPI,以及MapReduce2及其灵活性更强的执行模型(YARN)")
.endObject())
.execute()
.actionGet();
System.out.println("索引是否更新:"+response.isCreated());
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);
}
示例2: updateOrInsertInstance
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
@Override
public long updateOrInsertInstance(EsInstance instance) throws Exception {
UpdateResponse
response =
this.updateOrInsert(instance.getId(),
updateMapper.writeValueAsBytes(instance),
insertMapper.writeValueAsBytes(instance));
return response.isCreated() ? 0 : response.getVersion();
}
示例3: update
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
@Override
public long update(EsInstance instance) throws Exception {
UpdateResponse
response =
this.update(instance.getId(), updateMapper.writeValueAsBytes(instance),
instance.getVersion());
return response.getVersion();
}
示例4: updateOrInsertServiceMapping
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
@Override
public long updateOrInsertServiceMapping(EsServiceMapping serviceMapping) throws Exception {
UpdateResponse response = this.updateOrInsert(serviceMapping.getName(),
mapper.writeValueAsBytes(serviceMapping),
mapper.writeValueAsBytes(serviceMapping));
return response.isCreated() ? 0 : response.getVersion();
}
示例5: updateOrInsert
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
@Override
public long updateOrInsert(EsDailySnapshotInstance instance) throws Exception {
byte[] doc = essnapshotinstanceMapper.writeValueAsBytes(instance);
UpdateResponse
response =
this.updateOrInsert(instance.getId(), doc,
doc);
return response.getVersion();
}
示例6: update
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
@Override
public long update(EsDailySnapshotInstance instance) throws Exception {
byte[] doc = essnapshotinstanceMapper.writeValueAsBytes(instance);
UpdateResponse
response =
this.update(instance.getId(), doc, instance.getVersion());
return response.getVersion();
}
示例7: upsertIndex
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
/**
*
* @param index
* @param type
* @param id
* @throws Exception
*/
private static void upsertIndex(String index,String type,String id) throws Exception{
Client client = createTransportClient();
IndexRequest indexRequest = new IndexRequest(index, type, id)
.source(jsonBuilder()
.startObject()
.field("name", "Hadoop权威指南(第3版 修订版)")
.field("author", "Tom White")
.field("pubinfo", "清华大学出版社")
.field("pubtime", "2015-01-01")
.field("desc", "《Hadoop权威指南(第3版 修订版)》通过丰富的案例学习来解释Hadoop的幕后机理,阐述了Hadoop如何解决现实生活中的具体问题。第3版覆盖Hadoop的最新动态,包括新增的MapReduceAPI,以及MapReduce2及其灵活性更强的执行模型(YARN)")
.endObject());
UpdateRequest updateRequest = new UpdateRequest(index, type, id)
.doc(jsonBuilder()
.startObject()
.field("author", "华东师范大学数据科学与工程学院")
.endObject())
.upsert(indexRequest);
UpdateResponse response = client.update(updateRequest).get();
System.out.println("索引是否更新:"+response.isCreated());
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);
}
示例8: updateIndexByScript
import org.elasticsearch.action.update.UpdateResponse; //导入方法依赖的package包/类
/**
* 更新索引 https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
* @param index
* @param type
* @param id
*/
private static void updateIndexByScript(String index, String type, String id) throws Exception{
Client client = createTransportClient();
UpdateResponse response = client.prepareUpdate(index, type, id)
.setScript("ctx._source.author = \"闫洪磊\";" +
"ctx._source.name = \"Activiti实战\";" +
"ctx._source.pubinfo = \"机械工业出版社\";" +
"ctx._source.pubtime = \"2015-01-01\";" +
"ctx._source.desc = \"《Activiti实战 》立足于实践,不仅让读者知其然,全面掌握Activiti架构、功能、用法、技巧和最佳实践,广度足够;而且让读者知其所以然,深入理解Activiti的源代码实现、设计模式和PVM,深度也足够。《Activiti实战 》一共四个部分:准备篇(1~2章)介绍了Activiti的概念、特点、应用、体系结构,以及开发环境的搭建和配置;基础篇(3~4章)首先讲解了Activiti Modeler、Activiti Designer两种流程设计工具的详细使用,然后详细讲解了BPMN2.0规范;实战篇(5~14章)系统讲解了Activiti的用法、技巧和最佳实践,包含流程定义、流程实例、任务、子流程、多实例、事件以及监听器等;高级篇(15~21)通过集成WebService、规则引擎、JPA、ESB等各种服务和中间件来阐述了Activiti不仅仅是引擎,实际上是一个BPM平台,最后还通过源代码对它的设计模式及PVM进行了分析。\"", ScriptService.ScriptType.INLINE)
// .setScript("ctx._source.author = \"闫洪磊\"", ScriptService.ScriptType.INLINE)
// .setScript("ctx._source.name = \"Activiti实战\"", ScriptService.ScriptType.INLINE)
// .setScript("ctx._source.pubinfo = \"机械工业出版社\"", ScriptService.ScriptType.INLINE)
// .setScript("ctx._source.pubtime = \"2015-01-01\"", ScriptService.ScriptType.INLINE)
// .setScript("ctx._source.desc = \"《Activiti实战 》立足于实践,不仅让读者知其然,全面掌握Activiti架构、功能、用法、技巧和最佳实践,广度足够;而且让读者知其所以然,深入理解Activiti的源代码实现、设计模式和PVM,深度也足够。《Activiti实战 》一共四个部分:准备篇(1~2章)介绍了Activiti的概念、特点、应用、体系结构,以及开发环境的搭建和配置;基础篇(3~4章)首先讲解了Activiti Modeler、Activiti Designer两种流程设计工具的详细使用,然后详细讲解了BPMN2.0规范;实战篇(5~14章)系统讲解了Activiti的用法、技巧和最佳实践,包含流程定义、流程实例、任务、子流程、多实例、事件以及监听器等;高级篇(15~21)通过集成WebService、规则引擎、JPA、ESB等各种服务和中间件来阐述了Activiti不仅仅是引擎,实际上是一个BPM平台,最后还通过源代码对它的设计模式及PVM进行了分析。\"", ScriptService.ScriptType.INLINE)
.execute()
.actionGet();
System.out.println("索引是否更新:"+response.isCreated());
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);
}