|
|
@@ -330,20 +330,7 @@ public class SearchServiceImpl implements SearchService, InnerSearchService {
|
|
|
booleanQuery.add(brandQuery, BooleanClause.Occur.MUST);
|
|
|
}
|
|
|
logger.info(booleanQuery.toString());
|
|
|
- // TopDocs hits = indexSearcher.search(booleanQuery,
|
|
|
- // SearchConstants.TOP_NUM);
|
|
|
- // ScoreDoc[] scoreDocs = hits.scoreDocs;
|
|
|
- // for (ScoreDoc scoreDoc : scoreDocs) {
|
|
|
- // Set<String> fieldsToLoad = new HashSet<>();
|
|
|
- // fieldsToLoad.add(SearchConstants.COMPONENT_KINDID_FIELD);
|
|
|
- // Document document = indexSearcher.doc(scoreDoc.doc,
|
|
|
- // fieldsToLoad);
|
|
|
- // String cmp_kind_id =
|
|
|
- // document.get(SearchConstants.COMPONENT_KINDID_FIELD);
|
|
|
- // if (!StringUtils.isEmpty(cmp_kind_id)) {
|
|
|
- // kindIds.add(Long.parseLong(cmp_kind_id));
|
|
|
- // }
|
|
|
- // }
|
|
|
+
|
|
|
DistinctGroupCollector collector = new DistinctGroupCollector(SearchConstants.COMPONENT_KINDID_FIELD);
|
|
|
indexSearcher.search(booleanQuery, collector);
|
|
|
kindIds = collector.getValues();
|
|
|
@@ -401,17 +388,9 @@ public class SearchServiceImpl implements SearchService, InnerSearchService {
|
|
|
}
|
|
|
logger.info(booleanQuery.toString());
|
|
|
|
|
|
- TopDocs hits = indexSearcher.search(booleanQuery, SearchConstants.TOP_NUM);
|
|
|
- ScoreDoc[] scoreDocs = hits.scoreDocs;
|
|
|
- for (ScoreDoc scoreDoc : scoreDocs) {
|
|
|
- Set<String> fieldsToLoad = new HashSet<>();
|
|
|
- fieldsToLoad.add(SearchConstants.COMPONENT_BRANDID_FIELD);
|
|
|
- Document document = indexSearcher.doc(scoreDoc.doc, fieldsToLoad);
|
|
|
- String cmp_brand_id = document.get(SearchConstants.COMPONENT_BRANDID_FIELD);
|
|
|
- if (!StringUtils.isEmpty(cmp_brand_id)) {
|
|
|
- brandIds.add(Long.parseLong(cmp_brand_id));
|
|
|
- }
|
|
|
- }
|
|
|
+ DistinctGroupCollector collector = new DistinctGroupCollector(SearchConstants.COMPONENT_BRANDID_FIELD);
|
|
|
+ indexSearcher.search(booleanQuery, collector);
|
|
|
+ brandIds = collector.getValues();
|
|
|
} catch (IOException e) {
|
|
|
logger.error("", e);
|
|
|
} finally {
|