From 2fec35aa97996e2f9a3b721cdb622f90ff8cad9d Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Sat, 2 Jul 2022 15:49:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96es=E8=8E=B7=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/temp/shenjian/poi/GetPoiFromCommunity.groovy | 1 - .../com/fangjia/script/temp/shenjian/util/EsUtils.groovy | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromCommunity.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromCommunity.groovy index 1aab2c40b..f93b844d7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromCommunity.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromCommunity.groovy @@ -86,7 +86,6 @@ class GetPoiFromCommunity { static def findCommunities(){ QueryBuilder queryBuilder = QueryBuilders.boolQuery() - .filter(QueryBuilders.termQuery("city", "东莞")) .mustNot(QueryBuilders.termQuery("crawl_flag", 0)) List communities = EsUtils.scrollQuery("community", queryBuilder, Community.class) return communities diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/EsUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/EsUtils.groovy index ee66cfce7..b158c9351 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/EsUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/EsUtils.groovy @@ -35,7 +35,7 @@ class EsUtils { * @param * @return */ - public static List scrollQuery(String index, QueryBuilder boolQuery, Class clazz) { + public static List scrollQuery(String index, QueryBuilder boolQuery, Class clazz, def limitSize=300000) { List result = new ArrayList<>(); // 存活时间,当索引数据量特别大时,出现超时可能性大,此值适当调大 Scroll scroll = new Scroll(TimeValue.timeValueMinutes(30L)); @@ -61,7 +61,7 @@ class EsUtils { } } // 遍历搜索命中的数据,直到没有数据 - while (searchHits != null && searchHits.length > 0) { + while (searchHits != null && searchHits.length > 0 && result.size() < limitSize) { SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(scroll); try {