• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OpType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.action.index.IndexRequest.OpType的典型用法代码示例。如果您正苦于以下问题:Java OpType类的具体用法?Java OpType怎么用?Java OpType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OpType类属于org.elasticsearch.action.index.IndexRequest包,在下文中一共展示了OpType类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initFromMeta

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
private void initFromMeta() {
  index = environmentSubstitute(meta.getIndex());
  type = environmentSubstitute(meta.getType());
  batchSize = meta.getBatchSizeInt(this);
  try {
    timeout = Long.parseLong( environmentSubstitute(meta.getTimeOut()));
  } catch (NumberFormatException e) {
    timeout = null;
  }
  timeoutUnit = meta.getTimeoutUnit();
  isJsonInsert = meta.isJsonInsert();
  useOutput = meta.isUseOutput();
  stopOnError = meta.isStopOnError();
  
  columnsToJson = meta.getFields();
  this.hasFields =  columnsToJson.size() > 0;
  
  this.opType = StringUtils.isNotBlank(meta.getIdInField()) && meta.isOverWriteIfSameId() ?
      OpType.INDEX :
      OpType.CREATE;
  
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:ElasticSearchBulk.java


示例2: save

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
/**
 * Slower save, but high protected save.
 */
public void save() {
	IndexRequestBuilder create = Elasticsearch.getClient().prepareIndex(ES_INDEX, ES_TYPE, _id).setRefresh(true);
	create.setSource(MyDMAM.gson_kit.getGsonSimple().toJson(this));
	
	if (_id == null) {
		create.setCreate(true).setOpType(OpType.CREATE).setConsistencyLevel(WriteConsistencyLevel.ALL).setReplicationType(ReplicationType.SYNC);
		
		createAutogeneratedId();
		create.setId(_id);
		while (create.get().isCreated() == false) {
			createAutogeneratedId();
			create.setId(_id);
		}
	} else {
		create.get();
	}
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:21,代码来源:InternalId.java


示例3: initFromMeta

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
private void initFromMeta() {
  index = environmentSubstitute( meta.getIndex() );
  type = environmentSubstitute( meta.getType() );
  batchSize = meta.getBatchSizeInt( this );
  try {
    timeout = Long.parseLong( environmentSubstitute( meta.getTimeOut() ) );
  } catch ( NumberFormatException e ) {
    timeout = null;
  }
  timeoutUnit = meta.getTimeoutUnit();
  isJsonInsert = meta.isJsonInsert();
  useOutput = meta.isUseOutput();
  stopOnError = meta.isStopOnError();

  columnsToJson = meta.getFieldsMap();
  this.hasFields = columnsToJson.size() > 0;

  this.opType =
      StringUtils.isNotBlank( meta.getIdInField() ) && meta.isOverWriteIfSameId() ? OpType.INDEX : OpType.CREATE;

}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:22,代码来源:ElasticSearchBulk.java


示例4: parse

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
/**
 * Mostly just write the data you got from BigQuery into ElasticSearch.
 * 
 * @throws ElasticsearchException
 * @throws IOException
 * @throws InterruptedException
 */
private void parse(@Nonnull final List<TableRow> rows) throws ElasticsearchException, IOException, InterruptedException {
	final int size = rows.size();
	int count = 0;
	final String timestamp = String.valueOf(System.currentTimeMillis());
	int progress = 0;
	logger.info("Got {} results from BigQuery database", size);

	while (!stopThread && !rows.isEmpty()) {
		final TableRow row = rows.remove(0);
		final String[] jsonResult = getJson(row);
		final String source = jsonResult[0];
		final IndexRequestBuilder builder = esClient.prepareIndex(index, type);
		if (jsonResult[1] != null) {
			builder.setId(jsonResult[1]);
		}
		try {
			builder.setOpType(OpType.CREATE)
				.setReplicationType(ReplicationType.ASYNC)
				.setOperationThreaded(true)
				.setTimestamp(timestamp)
				.setSource(source)
				.setCreate(create)
				.execute()
				.actionGet();
			count++;
		} catch (DocumentAlreadyExistsException daee) {
			logger.trace("Document already exists, create flag is {}", daee, create);
		}
		if (++progress % 100 == 0) {
			logger.debug("Processed {} entries ({} percent done)", progress, Math.round((float) progress / (float) size * 100f));
		}
	}
	logger.info("Imported {} entries into ElasticSeach from BigQuery (some duplicates may have been skipped)", count);
	return;
}
 
开发者ID:mallocator,项目名称:Elasticsearch-BigQuery-River,代码行数:43,代码来源:BigQueryRiver.java


示例5: doItemUpdate

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
private void doItemUpdate(final Params params,
        final RequestHandler.OnErrorListener listener,
        final Map<String, Object> requestMap,
        final Map<String, Object> paramMap,
        final Map<String, Object> itemMap, final String index,
        final String type, final String itemIdField,
        final String timestampField, final Long itemId,
        final OpType opType, final RequestHandlerChain chain) {
    itemMap.put(itemIdField, itemId);
    itemMap.put(timestampField, new Date());
    final OnResponseListener<IndexResponse> responseListener = response -> {
        paramMap.put(itemIdField, itemId);
        chain.execute(params, listener, requestMap, paramMap);
    };
    final OnFailureListener failureListener = t -> {
        sleep(t);
        if (t instanceof DocumentAlreadyExistsException
                || t instanceof EsRejectedExecutionException) {
            execute(params, listener, requestMap, paramMap, chain);
        } else {
            listener.onError(t);
        }
    };
    client.prepareIndex(index, type, itemId.toString()).setSource(itemMap)
            .setRefresh(true).setOpType(opType)
            .execute(on(responseListener, failureListener));
}
 
开发者ID:codelibs,项目名称:elasticsearch-taste,代码行数:28,代码来源:ItemRequestHandler.java


示例6: doUserUpdate

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
private void doUserUpdate(final Params params,
        final RequestHandler.OnErrorListener listener,
        final Map<String, Object> requestMap,
        final Map<String, Object> paramMap,
        final Map<String, Object> userMap, final String index,
        final String type, final String userIdField,
        final String timestampField, final Long userId,
        final OpType opType, final RequestHandlerChain chain) {
    userMap.put(userIdField, userId);
    userMap.put(timestampField, new Date());

    final OnResponseListener<IndexResponse> responseListener = response -> {
        paramMap.put(userIdField, userId);
        chain.execute(params, listener, requestMap, paramMap);
    };
    final OnFailureListener failureListener = t -> {
        if (t instanceof DocumentAlreadyExistsException
                || t instanceof EsRejectedExecutionException) {
            sleep(t);
            execute(params, listener, requestMap, paramMap, chain);
        } else {
            listener.onError(t);
        }
    };
    client.prepareIndex(index, type, userId.toString()).setSource(userMap)
            .setRefresh(true).setOpType(opType)
            .execute(on(responseListener, failureListener));
}
 
开发者ID:codelibs,项目名称:elasticsearch-taste,代码行数:29,代码来源:UserRequestHandler.java


示例7: execute

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
@Override
public void execute(Tuple tuple) {
  try {
    String index = mapper.getIndex(tuple);
    String type = mapper.getType(tuple);
    String id = mapper.getId(tuple);
    String source = mapper.getSource(tuple);
    OpType opType = mapper.getOpType();
    client.prepareIndex(index, type).setId(id).setSource(source)
        .setOpType(opType).execute();
    collector.ack(tuple);
  } catch (Exception e) {
    collector.fail(tuple);
  }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:16,代码来源:EsIndexBolt.java


示例8: doItemCreation

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
private void doItemCreation(final Params params,
        final RequestHandler.OnErrorListener listener,
        final Map<String, Object> requestMap,
        final Map<String, Object> paramMap,
        final Map<String, Object> itemMap, final String index,
        final String type, final String itemIdField,
        final String timestampField, final RequestHandlerChain chain) {
    final OnResponseListener<SearchResponse> responseListener = response -> {
        validateRespose(response);

        Number currentId = null;
        final SearchHits hits = response.getHits();
        if (hits.getTotalHits() != 0) {
            final SearchHit[] searchHits = hits.getHits();
            final SearchHitField field = searchHits[0].getFields().get(
                    itemIdField);
            if (field != null) {
                currentId = field.getValue();
            }
        }
        final Long itemId;
        if (currentId == null) {
            itemId = Long.valueOf(1);
        } else {
            itemId = Long.valueOf(currentId.longValue() + 1);
        }
        doItemUpdate(params, listener, requestMap, paramMap, itemMap,
                index, type, itemIdField, timestampField, itemId,
                OpType.CREATE, chain);
    };
    final OnFailureListener failureListener = t -> {
        final List<Throwable> errorList = getErrorList(paramMap);
        if (errorList.size() >= maxRetryCount) {
            listener.onError(t);
        } else {
            sleep(t);
            errorList.add(t);
            doItemIndexExists(params, listener, requestMap, paramMap,
                    chain);
        }
    };
    client.prepareSearch(index).setTypes(type)
            .setQuery(QueryBuilders.matchAllQuery()).addField(itemIdField)
            .addSort(itemIdField, SortOrder.DESC).setSize(1)
            .execute(on(responseListener, failureListener));
}
 
开发者ID:codelibs,项目名称:elasticsearch-taste,代码行数:47,代码来源:ItemRequestHandler.java


示例9: doUserCreation

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
private void doUserCreation(final Params params,
        final RequestHandler.OnErrorListener listener,
        final Map<String, Object> requestMap,
        final Map<String, Object> paramMap,
        final Map<String, Object> userMap, final String index,
        final String type, final String userIdField,
        final String timestampField, final RequestHandlerChain chain) {
    final OnResponseListener<SearchResponse> responseListener = response -> {
        validateRespose(response);

        Number currentId = null;
        final SearchHits hits = response.getHits();
        if (hits.getTotalHits() != 0) {
            final SearchHit[] searchHits = hits.getHits();
            final SearchHitField field = searchHits[0].getFields().get(
                    userIdField);
            if (field != null) {
                currentId = field.getValue();
            }
        }
        final Long userId;
        if (currentId == null) {
            userId = Long.valueOf(1);
        } else {
            userId = Long.valueOf(currentId.longValue() + 1);
        }
        doUserUpdate(params, listener, requestMap, paramMap, userMap,
                index, type, userIdField, timestampField, userId,
                OpType.CREATE, chain);
    };
    final OnFailureListener failureListener = t -> {
        final List<Throwable> errorList = getErrorList(paramMap);
        if (errorList.size() >= maxRetryCount) {
            listener.onError(t);
        } else {
            sleep(t);
            errorList.add(t);
            doUserIndexExists(params, listener, requestMap, paramMap,
                    chain);
        }
    };
    client.prepareSearch(index).setTypes(type)
            .setQuery(QueryBuilders.matchAllQuery()).addField(userIdField)
            .addSort(userIdField, SortOrder.DESC).setSize(1)
            .execute(on(responseListener, failureListener));
}
 
开发者ID:codelibs,项目名称:elasticsearch-taste,代码行数:47,代码来源:UserRequestHandler.java


示例10: getOpType

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
@Override
public OpType getOpType() {
  return OpType.INDEX;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:5,代码来源:EsDefaultIndexMapper.java


示例11: getOpType

import org.elasticsearch.action.index.IndexRequest.OpType; //导入依赖的package包/类
public OpType getOpType(); 
开发者ID:alibaba,项目名称:jstorm,代码行数:2,代码来源:EsIndexMapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFTableFeaturesStatsReply类代码示例发布时间:2022-05-22
下一篇:
Java ClientService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap