|
@@ -7,6 +7,7 @@ import com.gree.mall.manager.utils.CommonUtils;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
|
|
import org.springframework.data.elasticsearch.core.SearchHit;
|
|
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
|
@@ -93,12 +94,38 @@ public class EsLogic {
|
|
|
must.must(QueryBuilders.termsQuery("websitNumber.keyword",websitNumbers));
|
|
|
}
|
|
|
NativeSearchQuery titleBuild = new NativeSearchQueryBuilder().withQuery(titleQueryBuilder).build();
|
|
|
- NativeSearchQuery dataBuild = new NativeSearchQueryBuilder().withQuery(must).build();
|
|
|
+ NativeSearchQuery dataBuild = new NativeSearchQueryBuilder()
|
|
|
+ .withQuery(must)
|
|
|
+ .withPageable(PageRequest.of(0, 10000))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ NativeSearchQuery dataBuild2 = new NativeSearchQueryBuilder()
|
|
|
+ .withQuery(must)
|
|
|
+ .withPageable(PageRequest.of(1, 10000))
|
|
|
+ .build();
|
|
|
+ NativeSearchQuery dataBuild3 = new NativeSearchQueryBuilder()
|
|
|
+ .withQuery(must)
|
|
|
+ .withPageable(PageRequest.of(2, 10000))
|
|
|
+ .build();
|
|
|
|
|
|
List<SearchHit<CommonListES>> searchHits1 = elasticsearchRestTemplate.search(titleBuild, CommonListES.class).getSearchHits();
|
|
|
List<SearchHit<CommonListES>> searchHits2 = elasticsearchRestTemplate.search(dataBuild, CommonListES.class).getSearchHits();
|
|
|
+
|
|
|
+
|
|
|
List<CommonListES> titles = searchHits1.stream().map(SearchHit<CommonListES>::getContent).collect(Collectors.toList());
|
|
|
List<CommonListES> datas = searchHits2.stream().map(SearchHit<CommonListES>::getContent).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ if (datas.size() == 10000) {
|
|
|
+ List<SearchHit<CommonListES>> searchHits3 = elasticsearchRestTemplate.search(dataBuild2, CommonListES.class).getSearchHits();
|
|
|
+ datas.addAll(searchHits3.stream().map(SearchHit<CommonListES>::getContent).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (datas.size() == 20000) {
|
|
|
+ List<SearchHit<CommonListES>> searchHits4 = elasticsearchRestTemplate.search(dataBuild3, CommonListES.class).getSearchHits();
|
|
|
+ datas.addAll(searchHits4.stream().map(SearchHit<CommonListES>::getContent).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
titles.addAll(datas);
|
|
|
|
|
|
return titles;
|