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


Java QueryBuilder.toString方法代码示例

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


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

示例1: explain

import org.elasticsearch.index.query.QueryBuilder; //导入方法依赖的package包/类
@Override
public String explain() {
    String baseExplain = super.explain();
    Where where = this.connectedWhere;
    QueryBuilder explan = null;
    try {
        if(where!=null)
            explan = QueryMaker.explan(where,false);
    } catch (SqlParseException e) {
    }
    String conditions = explan == null ? "Could not parse conditions" : explan.toString();
    String nestedExplain =  "Nested Loops \n run first query , and for each result run second query with additional conditions :\n" +conditions +"\n"+  baseExplain;
    return nestedExplain;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:15,代码来源:NestedLoopsElasticRequestBuilder.java

示例2: delByQuery

import org.elasticsearch.index.query.QueryBuilder; //导入方法依赖的package包/类
protected boolean delByQuery(QueryBuilder builder, Task task) {
	BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
	SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName, typeName)
			.setQuery(builder).setSize(100)
			.setScroll(SCROLL_TIMEOUT);
	SearchResponse response = searchRequestBuilder.get();
	String query = builder.toString();
	int num = bulkRequestBuilder.numberOfActions();
	while(true) {
		for(SearchHit hit:response.getHits()) {
			bulkRequestBuilder.add(new DeleteRequest(indexName, typeName, hit.getId()));
			if(task!=null)
				task.increaseCount();
		}
		response = client.prepareSearchScroll(response.getScrollId())
				.setScroll(SCROLL_TIMEOUT).get();
		if(response.getHits().getHits().length == 0) {
			if(task!=null)
				task.setDescription("按照query:%s 加载数据,已经添加%s条, 准备执行删除...", query, num);
			LOG.debug("准备执行删除, query:" + builder.toString());
			break;
		} else {
			if(task!=null)
				task.setDescription("按query:%s删除数据, 已添加%s条", query, num);
			LOG.debug("删除数据已添加" + num + "条, query:" + query);
		}
	}
	if(num <= 0) {
		if(task!=null)
			task.setDescription("执行删除时未找到数据, query:", query);
		LOG.debug("执行删除时未找到数据,请检查参数,query:" + query);
		return false;
	}
	BulkResponse bulkResponse = bulkRequestBuilder.get();
	if(bulkResponse.hasFailures()) {
		if(task!=null)
			task.setDescription("按query:%s删除部分数据失败,由于%s", query, bulkResponse.buildFailureMessage());
		LOG.error("删除部分数据失败, query:" + query + ", 由于 " + bulkResponse.buildFailureMessage());
	} else {
		if(task!=null)
			task.setDescription("删除数据成功, query:%s, 耗时:%sms", query, bulkResponse.getTookInMillis());
		LOG.error("删除数据成功, query:" + query + ", 耗时:" + bulkResponse.getTookInMillis() + "ms");
	}
	return bulkResponse.hasFailures();
}
 
开发者ID:TransientBuckwheat,项目名称:nest-spider,代码行数:46,代码来源:ElasticsearchDAO.java


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