完善es返回数据条数可配置,而不是默认的10条

This commit is contained in:
zhouxiunai
2019-01-28 11:16:32 +08:00
parent f06ca96b4b
commit a908074090
2 changed files with 7 additions and 2 deletions
@@ -9,6 +9,7 @@ import java.util.Map;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -27,6 +28,9 @@ import com.gzzn.omms.adminapi.utils.DateUtils;
@RestController @RestController
public class HistoryFlightDataController { public class HistoryFlightDataController {
@Value("${elasticsearch.maxSize}")
private Integer maxSize; //es单次返回最大条数
/** /**
* 历史航班数据索引 * 历史航班数据索引
*/ */
@@ -79,7 +83,7 @@ public class HistoryFlightDataController {
} }
String sortField = "SODT";//计划时间 默认倒序 String sortField = "SODT";//计划时间 默认倒序
SortOrder sortOrder = SortOrder.ASC; SortOrder sortOrder = SortOrder.ASC;
List<Map<String, Object>> list = ElasticsearchUtil.searchListData(INDEX_NAME, ES_TYPE, boolQuery, null, null, sortField,sortOrder, null); List<Map<String, Object>> list = ElasticsearchUtil.searchListData(INDEX_NAME, ES_TYPE, boolQuery, maxSize, null, sortField,sortOrder, null);
return ResponseDto.success(list); return ResponseDto.success(list);
} }
+2 -1
View File
@@ -60,4 +60,5 @@ elasticsearch:
pool: 5 pool: 5
#注意cluster.name需要与config/elasticsearch.yml中的cluster.name一致 #注意cluster.name需要与config/elasticsearch.yml中的cluster.name一致
cluster: cluster:
name: docker-cluster name: docker-cluster
maxSize: 10000