| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.common.solr;
|
1 |
package com.spice.profitmandi.common.solr;
|
| 2 |
|
2 |
|
| 3 |
import com.google.gson.JsonArray;
|
- |
|
| 4 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
3 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
import com.spice.profitmandi.common.web.client.RestClient;
|
5 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 7 |
import org.apache.commons.lang3.StringUtils;
|
6 |
import org.apache.commons.lang3.StringUtils;
|
| 8 |
import org.apache.http.conn.HttpHostConnectException;
|
7 |
import org.apache.http.conn.HttpHostConnectException;
|
| Line 13... |
Line 12... |
| 13 |
import org.springframework.beans.factory.annotation.Autowired;
|
12 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 14 |
import org.springframework.beans.factory.annotation.Value;
|
13 |
import org.springframework.beans.factory.annotation.Value;
|
| 15 |
import org.springframework.stereotype.Service;
|
14 |
import org.springframework.stereotype.Service;
|
| 16 |
|
15 |
|
| 17 |
import java.util.*;
|
16 |
import java.util.*;
|
| - |
|
17 |
import java.util.stream.Collectors;
|
| 18 |
|
18 |
|
| 19 |
@Service("solrServiceCommon")
|
19 |
@Service("solrServiceCommon")
|
| 20 |
public class SolrService {
|
20 |
public class SolrService {
|
| 21 |
|
21 |
|
| 22 |
private static final Logger logger = LogManager.getLogger(SolrService.class);
|
22 |
private static final Logger logger = LogManager.getLogger(SolrService.class);
|
| Line 46... |
Line 46... |
| 46 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
46 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
| 47 |
if (categoryIds != null && categoryIds.size() > 0) {
|
47 |
if (categoryIds != null && categoryIds.size() > 0) {
|
| 48 |
params.put("q", params.get("q") + " +filter(categoryId_i:(" + StringUtils.join(categoryIds, " ") + "))");
|
48 |
params.put("q", params.get("q") + " +filter(categoryId_i:(" + StringUtils.join(categoryIds, " ") + "))");
|
| 49 |
}
|
49 |
}
|
| 50 |
if (brands.size() > 0) {
|
50 |
if (brands.size() > 0) {
|
| - |
|
51 |
brands = brands.stream().map(x -> x.replaceAll(" ", "\\ ")).collect(Collectors.toList());
|
| 51 |
params.put("q", params.get("q") + " AND brand_ss:(" + StringUtils.join(brands, " ") + ")");
|
52 |
params.put("q", params.get("q") + " AND brand_ss:(" + StringUtils.join(brands, " ") + ")");
|
| 52 |
}
|
53 |
}
|
| 53 |
if (activeOnly) {
|
54 |
if (activeOnly) {
|
| 54 |
params.put("q", params.get("q") + " AND active_b:true");
|
55 |
params.put("q", params.get("q") + " AND active_b:true");
|
| 55 |
}
|
56 |
}
|