|
|
@@ -295,7 +295,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
logger.info(booleanQuery.toString());
|
|
|
|
|
|
- Sort sort = new Sort(SortField.FIELD_SCORE);
|
|
|
+ Sort sort = sortComponent();
|
|
|
|
|
|
TopDocs hits;
|
|
|
if (pageParams.getPage() > 1) {// 不是第一页
|
|
|
@@ -356,6 +356,30 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return booleanQuery;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return 器件排序规则
|
|
|
+ */
|
|
|
+ private Sort sortComponent() {
|
|
|
+ // 器件(访问量 > 搜索次数) > 品牌(权重 > 访问量 > 搜索次数) > 类目(访问量 > 搜索次数)
|
|
|
+ SortField componentVisitCountSortField = new SortField(SearchConstants.COMPONENT_VISIT_COUNT_FIELD, Type.LONG, true);
|
|
|
+ componentVisitCountSortField.setMissingValue(Long.MIN_VALUE);
|
|
|
+ SortField componentSearchCountSortField = new SortField(SearchConstants.COMPONENT_SEARCH_COUNT_FIELD, Type.LONG, true);
|
|
|
+ componentSearchCountSortField.setMissingValue(Long.MIN_VALUE);
|
|
|
+ SortField brandWeightSortField = new SortField(SearchConstants.COMPONENT_BR_WEIGHT_FIELD, Type.DOUBLE, true);
|
|
|
+ brandWeightSortField.setMissingValue(Double.MIN_VALUE);
|
|
|
+ SortField brandVisitCountSortField = new SortField(SearchConstants.COMPONENT_BR_VISIT_COUNT_FIELD, Type.LONG, true);
|
|
|
+ brandVisitCountSortField.setMissingValue(Long.MIN_VALUE);
|
|
|
+ SortField brandSearchCountSortField = new SortField(SearchConstants.COMPONENT_BR_SEARCH_COUNT_FIELD, Type.LONG, true);
|
|
|
+ brandSearchCountSortField.setMissingValue(Long.MIN_VALUE);
|
|
|
+ SortField kindVisitCountSortField = new SortField(SearchConstants.COMPONENT_KI_VISIT_COUNT_FIELD, Type.LONG, true);
|
|
|
+ kindVisitCountSortField.setMissingValue(Long.MIN_VALUE);
|
|
|
+ SortField kindSearchCountSortField = new SortField(SearchConstants.COMPONENT_KI_SEARCH_COUNT_FIELD, Type.LONG, true);
|
|
|
+ kindSearchCountSortField.setMissingValue(Long.MIN_VALUE);
|
|
|
+ return new Sort(componentVisitCountSortField, componentSearchCountSortField,
|
|
|
+ brandWeightSortField, brandVisitCountSortField, brandSearchCountSortField,
|
|
|
+ kindVisitCountSortField, kindSearchCountSortField);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) {
|
|
|
if (SearchUtils.isKeywordInvalid(keyword)) {
|