本文整理汇总了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;
}