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


Java UpdateRequestBuilder.get方法代码示例

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


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

示例1: testInvalidUpdateScript

import org.elasticsearch.action.update.UpdateRequestBuilder; //导入方法依赖的package包/类
public void testInvalidUpdateScript() throws Exception {
    try {
        createIndex("test_index");
        ensureGreen("test_index");
        indexRandom(true, client().prepareIndex("test_index", "doc", "1").setSource("text_field", "text"));
        UpdateRequestBuilder urb = client().prepareUpdate().setIndex("test_index");
        urb.setType("doc");
        urb.setId("1");
        urb.setScript(new Script(ScriptType.INLINE, ExpressionScriptEngineService.NAME, "0", Collections.emptyMap()));
        urb.get();
        fail("Expression scripts should not be allowed to run as update scripts.");
    } catch (Exception e) {
        String message = e.getMessage();
        assertThat(message + " should have contained failed to execute", message.contains("failed to execute"), equalTo(true));
        message = e.getCause().getMessage();
        assertThat(message + " should have contained not supported", message.contains("not supported"), equalTo(true));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:MoreExpressionTests.java

示例2: upsertProduct

import org.elasticsearch.action.update.UpdateRequestBuilder; //导入方法依赖的package包/类
/**
 * Upsert the given product into ES index.
 *
 * @param product given product object
 */
public void upsertProduct(Product product) throws InvalidProtocolBufferException {
  log.debug("save product into ES");
  final UpdateRequestBuilder updateRequestBuilder =
      esClient
          .prepareUpdate(INDEX, TYPE, String.valueOf(product.getProductId()))
          .setDoc(
              jsonPrinter
                  .includingDefaultValueFields()
                  .omittingInsignificantWhitespace()
                  .print(product)
          )
          .setDocAsUpsert(true);
  updateRequestBuilder.get();
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:20,代码来源:ProductDao.java

示例3: update

import org.elasticsearch.action.update.UpdateRequestBuilder; //导入方法依赖的package包/类
private UpdateResponse update(Boolean detectNoop, long expectedVersion, XContentBuilder xContentBuilder) {
    UpdateRequestBuilder updateRequest = client().prepareUpdate("test", "type1", "1")
            .setDoc(xContentBuilder)
            .setDocAsUpsert(true)
            .setFields("_source");
    if (detectNoop != null) {
        updateRequest.setDetectNoop(detectNoop);
    }
    UpdateResponse updateResponse = updateRequest.get();
    assertThat(updateResponse.getGetResult(), notNullValue());
    assertEquals(expectedVersion, updateResponse.getVersion());
    return updateResponse;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:UpdateNoopIT.java

示例4: patchObject

import org.elasticsearch.action.update.UpdateRequestBuilder; //导入方法依赖的package包/类
public UpdateResponse patchObject(String backendId, String type, String id, long version, ObjectNode object,
		String updatedBy) {

	object.with("meta").removeAll()//
			.put("updatedBy", updatedBy)//
			.put("updatedAt", DateTime.now().toString());

	UpdateRequestBuilder update = Start.get().getElasticClient().prepareUpdate(backendId, type, id)
			.setDoc(object.toString());

	if (version > 0)
		update.setVersion(version);

	return update.get();
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:16,代码来源:DataStore.java

示例5: update

import org.elasticsearch.action.update.UpdateRequestBuilder; //导入方法依赖的package包/类
@Override
public IndexResponse update(
        DocumentIdentifier id, UpdateScript script, UpdateOptions options, EzSecurityToken token)
        throws TException {
    // Ensure we can see the ID
    ensureVisible(id, token);

    if (!script.isSetScript()) {
        final String errMsg = "No script was set for call to update()!";
        logger.info(errMsg);
        throw new TException(errMsg);
    }

    final UpdateRequestBuilder updateRequest =
            client.prepareUpdate(indexName, id.getType(), id.getId()).setRefresh(true);

    updateRequest.setScript(script.getScript());
    if (script.isSetParameters()) {
        for (final Map.Entry<String, String> entry : script.getParameters().entrySet()) {
            updateRequest.addScriptParam(entry.getKey(), entry.getValue());
        }
    }

    updateRequest.setRetryOnConflict(options.getRetryCount());

    final UpdateResponse response = updateRequest.get();
    return new IndexResponse().set_id(response.getId()).set_type(response.getType())
            .set_version(response.getVersion()).setSuccess(true);
}
 
开发者ID:ezbake,项目名称:ezelastic,代码行数:30,代码来源:ElasticClient.java

示例6: executeRequest

import org.elasticsearch.action.update.UpdateRequestBuilder; //导入方法依赖的package包/类
public void executeRequest(HistoryEvent historyEvent) {
  try {
    if (filterEvents(historyEvent)) {
      return;
    }

    UpdateRequestBuilder updateRequestBuilder = prepareUpdateRequest(historyEvent);

    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(ElasticSearchHelper.convertRequestToJson(updateRequestBuilder.request()));
    }

    UpdateResponse updateResponse;
    if (WAIT_FOR_RESPONSE > 0) {
      updateResponse = updateRequestBuilder.get(TimeValue.timeValueSeconds(WAIT_FOR_RESPONSE));
    } else {
      updateResponse = updateRequestBuilder.get();
    }

    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("[" + updateResponse.getIndex() +
          "][" + updateResponse.getType() +
          "][update] process instance with id '" + updateResponse.getId() + "'");
      LOGGER.log(Level.FINE, "Source: " + updateResponse.getGetResult().sourceAsString());
    }
  } catch (IOException e) {
    LOGGER.log(Level.SEVERE, e.getMessage(), e);
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-elasticsearch,代码行数:30,代码来源:ElasticSearchDefaultIndexStrategy.java


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