當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。