本文整理匯總了Java中org.elasticsearch.action.search.SearchRequestBuilder.setPostFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchRequestBuilder.setPostFilter方法的具體用法?Java SearchRequestBuilder.setPostFilter怎麽用?Java SearchRequestBuilder.setPostFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.action.search.SearchRequestBuilder
的用法示例。
在下文中一共展示了SearchRequestBuilder.setPostFilter方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: query
import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private SearchResponse query(UAVHttpMessage data, QueryBuilder queryBuilder, QueryBuilder postFilter,
List<SortBuilder> sorts) {
String date = data.getRequest("indexdate");
String currentIndex;
if (date != null) {
// 指定index
currentIndex = this.indexMgr.getIndexByDate(date);
}
else {
// current index
currentIndex = this.indexMgr.getCurrentIndex();
}
SearchRequestBuilder srb = client.getClient().prepareSearch(currentIndex)
.setTypes(ThreadAnalysisIndexMgr.JTA_TABLE).setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
int from = DataConvertHelper.toInt(data.getRequest("from"), -1);
int size = DataConvertHelper.toInt(data.getRequest("size"), -1);
if (from != -1 && size != -1) {
srb = srb.setFrom(from).setSize(size);
}
srb.setQuery(queryBuilder);
if (postFilter != null) {
srb.setPostFilter(postFilter);
}
for (SortBuilder sb : sorts) {
srb.addSort(sb);
}
SearchResponse sr = srb.get(TimeValue.timeValueMillis(timeout));
return sr;
}
示例2: query
import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
/**
*
* @param data
* @param queryBuilder
* @param postFilter
* @return
*/
@SuppressWarnings("rawtypes")
private SearchResponse query(UAVHttpMessage data, QueryBuilder queryBuilder, QueryBuilder postFilter,
SortBuilder[] sorts) {
String date = data.getRequest("indexdate");
String currentIndex;
if (date != null) {
// 指定index
currentIndex = this.indexMgr.getIndexByDate(date);
}
else {
// current index
currentIndex = this.indexMgr.getCurrentIndex();
}
SearchRequestBuilder srb = client.getClient().prepareSearch(currentIndex)
.setTypes(InvokeChainIndexMgr.IVC_Table).setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
int from = DataConvertHelper.toInt(data.getRequest("from"), -1);
int size = DataConvertHelper.toInt(data.getRequest("size"), -1);
if (from != -1 && size != -1) {
srb = srb.setFrom(from).setSize(size);
}
srb.setQuery(queryBuilder);
if (postFilter != null) {
srb.setPostFilter(postFilter);
}
if (sorts != null && sorts.length > 0) {
for (SortBuilder sb : sorts) {
srb.addSort(sb);
}
}
SearchResponse sr = srb.get(TimeValue.timeValueMillis(timeout));
return sr;
}
示例3: query
import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private SearchResponse query(UAVHttpMessage data, QueryBuilder queryBuilder, QueryBuilder postFilter,
SortBuilder[] sorts) {
String appid = data.getRequest("appid");
if (appid == null) {
data.putResponse("rs", "ERR");
data.putResponse("msg", "appid is required");
return null;
}
String indexDate = data.getRequest("indexdate");
String currentIndex;
if (indexDate != null) {
// 獲得指定的index
currentIndex = this.indexMgr.getIndexByDate(indexDate, appid);
}
else {
// get current index
currentIndex = this.indexMgr.getCurrentIndex(appid);
}
SearchRequestBuilder srb = client.getClient().prepareSearch(currentIndex).setTypes(buildTypes(data))
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
int from = DataConvertHelper.toInt(data.getRequest("from"), -1);
int size = DataConvertHelper.toInt(data.getRequest("size"), -1);
if (from != -1 && size != -1) {
srb = srb.setFrom(from).setSize(size);
}
srb.setQuery(queryBuilder);
if (postFilter != null) {
srb.setPostFilter(postFilter);
}
if (sorts != null && sorts.length > 0) {
for (SortBuilder sb : sorts) {
srb.addSort(sb);
}
}
SearchResponse sr = srb.get(TimeValue.timeValueMillis(timeout));
return sr;
}
示例4: query
import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private SearchResponse query(UAVHttpMessage data, QueryBuilder queryBuilder, QueryBuilder postFilter,
SortBuilder[] sorts) {
String appid = data.getRequest("appid");
String indexDate = data.getRequest("indexdate");
String currentIndex;
if (indexDate != null) {
// 獲得指定的index
currentIndex = this.indexMgr.getIndexByDate(indexDate, appid);
}
else {
// get current index
currentIndex = this.indexMgr.getCurrentIndex(appid);
}
// get logtype for search
SearchRequestBuilder srb = null;
if (StringHelper.isEmpty(data.getRequest("logtype"))) {
srb = client.getClient().prepareSearch(currentIndex).setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
}
else {
String logType = data.getRequest("logtype").replace('.', '_');
srb = client.getClient().prepareSearch(currentIndex).setTypes(logType)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
}
int from = DataConvertHelper.toInt(data.getRequest("from"), -1);
int size = DataConvertHelper.toInt(data.getRequest("size"), -1);
if (from != -1 && size != -1) {
long startLine = DataConvertHelper.toLong(data.getRequest("sline"), -1);
long endLine = DataConvertHelper.toLong(data.getRequest("eline"), -1);
// 判斷如果隻有endline則需要將結果倒序,取其前100行,然後在返回響應時再逆序回來,從而取到endline前的100行
if (startLine == -1 && endLine > -1) {
srb = srb.addSort("l_timestamp", SortOrder.DESC).addSort("l_num", SortOrder.DESC).setFrom(from)
.setSize(size);
}
else {
srb = srb.setFrom(from).setSize(size);
}
}
srb.setQuery(queryBuilder);
if (postFilter != null) {
srb.setPostFilter(postFilter);
}
if (sorts != null && sorts.length > 0) {
for (SortBuilder sb : sorts) {
srb.addSort(sb);
}
}
SearchResponse sr = srb.get(TimeValue.timeValueMillis(timeout));
return sr;
}