|
@@ -131,9 +131,9 @@ public class SearchServiceImpl implements SearchService {
|
|
|
* @throws IOException 输入异常
|
|
|
*/
|
|
|
@Override
|
|
|
- public SPage<Long> getProductIds(Long enUU, String keyword, Integer page, Integer size, String type) throws IOException {
|
|
|
+ public SPage<Long> getProductIds(Long enUU, String keyword, Integer page, Integer size, String type, Boolean duplicate) throws IOException {
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
- SPage<Document> documents = getProductDocuments(enUU, keyword, page, size, type);
|
|
|
+ SPage<Document> documents = getProductDocuments(enUU, keyword, page, size, type, duplicate);
|
|
|
SPage<Long> sPage = new SPage<>(documents.getTotalPage(), documents.getTotalElement(), documents.getPage(),
|
|
|
documents.getSize(), documents.isFirst(), documents.isLast());
|
|
|
for (Document document : documents.getContent()) {
|
|
@@ -526,7 +526,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private SPage<Document> getProductDocuments(Long enUU, String keyword, Integer page, Integer size, String type) throws IOException {
|
|
|
+ private SPage<Document> getProductDocuments(Long enUU, String keyword, Integer page, Integer size, String type, Boolean duplicate) throws IOException {
|
|
|
// if (SearchUtils.isKeywordInvalid(keyword)) {
|
|
|
// throw new IllegalArgumentException("搜索关键词无效:" + keyword);
|
|
|
// }
|
|
@@ -544,13 +544,21 @@ public class SearchServiceImpl implements SearchService {
|
|
|
booleanQuery.add(q1, BooleanClause.Occur.MUST);
|
|
|
if (!StringUtils.isEmpty(keyword)) {
|
|
|
BooleanQuery q2 = new BooleanQuery();
|
|
|
- q2.add(createQuery(SearchConstants.PRODUCT_PRIVATE_KIND_FIELD, keyword, true,1), BooleanClause.Occur.SHOULD);
|
|
|
- q2.add(createQuery(SearchConstants.PRODUCT_PRIVATE_PBRANDEN_FIELD, keyword, true,1), BooleanClause.Occur.SHOULD);
|
|
|
- q2.add(createQuery(SearchConstants.PRODUCT_PRIVATE_PCMPCODE_FIELD, keyword, true,1), BooleanClause.Occur.SHOULD);
|
|
|
+ if (!duplicate) {
|
|
|
+ q2.add(createQuery(SearchConstants.PRODUCT_PRIVATE_KIND_FIELD, keyword.toLowerCase(), true,1), BooleanClause.Occur.SHOULD);
|
|
|
+ q2.add(createQuery(SearchConstants.PRODUCT_PRIVATE_PBRANDEN_FIELD, keyword.toLowerCase(), true,1), BooleanClause.Occur.SHOULD);
|
|
|
+ }
|
|
|
+ q2.add(createQuery(SearchConstants.PRODUCT_PRIVATE_PCMPCODE_FIELD, keyword.toLowerCase(), true,1), BooleanClause.Occur.SHOULD);
|
|
|
booleanQuery.add(q2, BooleanClause.Occur.MUST);
|
|
|
}
|
|
|
- logger.info(booleanQuery.toString());
|
|
|
- return getDocuments(SearchConstants.PRODUCTS_PRIVATE_TABLE_NAME, booleanQuery, new Sort(sortProduct(keyword)), page, size);
|
|
|
+ if (Boolean.valueOf(duplicate)) {
|
|
|
+ DuplicateFilter duplicateFilter = new DuplicateFilter(SearchConstants.PRODUCT_PRIVATE_PCMPCODE_FIELD);
|
|
|
+ logger.info(booleanQuery.toString());
|
|
|
+ return getDocuments(SearchConstants.PRODUCTS_PRIVATE_TABLE_NAME, booleanQuery, new Sort(sortProduct(keyword)), page, size, duplicateFilter);
|
|
|
+ } else {
|
|
|
+ logger.info(booleanQuery.toString());
|
|
|
+ return getDocuments(SearchConstants.PRODUCTS_PRIVATE_TABLE_NAME, booleanQuery, new Sort(sortProduct(keyword)), page, size);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|