| 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;
|
| 3 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
4 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 5 |
import com.spice.profitmandi.common.web.client.RestClient;
|
6 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 6 |
import org.apache.commons.lang3.StringUtils;
|
7 |
import org.apache.commons.lang3.StringUtils;
|
| 7 |
import org.apache.http.conn.HttpHostConnectException;
|
8 |
import org.apache.http.conn.HttpHostConnectException;
|
| Line 24... |
Line 25... |
| 24 |
private String solrUrl;
|
25 |
private String solrUrl;
|
| 25 |
|
26 |
|
| 26 |
@Autowired
|
27 |
@Autowired
|
| 27 |
private RestClient restClient;
|
28 |
private RestClient restClient;
|
| 28 |
|
29 |
|
| 29 |
public String getContent(String queryTerm, List<Integer> categoryIds, List<String> brands, int limit, boolean activeOnly) throws Exception {
|
30 |
public String getContent(String queryTerm, List<Integer> categoryIds, List<String> brands, int limit,
|
| - |
|
31 |
boolean activeOnly) throws Exception {
|
| - |
|
32 |
|
| - |
|
33 |
JSONArray docs = this.getContentDocs(queryTerm, categoryIds, brands, limit, activeOnly);
|
| - |
|
34 |
return docs.toString();
|
| - |
|
35 |
}
|
| - |
|
36 |
|
| - |
|
37 |
public JSONArray getContentDocs(String queryTerm, List<Integer> categoryIds, List<String> brands, int limit,
|
| - |
|
38 |
boolean activeOnly) throws Exception {
|
| 30 |
Map<String, String> params = new HashMap<>();
|
39 |
Map<String, String> params = new HashMap<>();
|
| 31 |
List<String> mandatoryQ = new ArrayList<>();
|
40 |
List<String> mandatoryQ = new ArrayList<>();
|
| 32 |
if (queryTerm != null && !queryTerm.equals("null")) {
|
41 |
if (queryTerm != null && !queryTerm.equals("null")) {
|
| 33 |
mandatoryQ.add(String.format("+(%s)", "*" + queryTerm + "*"));
|
42 |
mandatoryQ.add(String.format("+(%s)", "*" + queryTerm + "*"));
|
| 34 |
} else {
|
43 |
} else {
|
| Line 62... |
Line 71... |
| 62 |
} catch (HttpHostConnectException e) {
|
71 |
} catch (HttpHostConnectException e) {
|
| 63 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
72 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| 64 |
}
|
73 |
}
|
| 65 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
74 |
JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
|
| 66 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
75 |
JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
|
| 67 |
return docs.toString();
|
76 |
return docs;
|
| 68 |
}
|
77 |
}
|
| 69 |
|
78 |
|
| 70 |
public Map<Integer, JSONObject> getContentByCatalogIds(List<Integer> catalogIds) throws Exception {
|
79 |
public Map<Integer, JSONObject> getContentByCatalogIds(List<Integer> catalogIds) throws Exception {
|
| 71 |
Map<Integer, JSONObject> documentMap = new HashMap<>();
|
80 |
Map<Integer, JSONObject> documentMap = new HashMap<>();
|
| 72 |
Map<String, String> params = new HashMap<>();
|
81 |
Map<String, String> params = new HashMap<>();
|