Subversion Repositories SmartDukaan

Rev

Rev 30080 | Rev 30267 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30080 Rev 30262
Line 24... Line 24...
24
	private String solrUrl;
24
	private String solrUrl;
25
 
25
 
26
	@Autowired
26
	@Autowired
27
	private RestClient restClient;
27
	private RestClient restClient;
28
 
28
 
29
	public String getContent(String queryTerm, int categoryId, List<String> brands, int limit, boolean activeOnly) throws Exception {
29
	public String getContent(String queryTerm, List<Integer> categoryIds, List<String> brands, int limit, boolean activeOnly) throws Exception {
30
		Map<String, String> params = new HashMap<>();
30
		Map<String, String> params = new HashMap<>();
31
		List<String> mandatoryQ = new ArrayList<>();
31
		List<String> mandatoryQ = new ArrayList<>();
32
		if (queryTerm != null && !queryTerm.equals("null")) {
32
		if (queryTerm != null && !queryTerm.equals("null")) {
33
			mandatoryQ.add(String.format("+(%s)", "*" + queryTerm + "*"));
33
			mandatoryQ.add(String.format("+(%s)", "*" + queryTerm + "*"));
34
		} else {
34
		} else {
35
			queryTerm = null;
35
			queryTerm = null;
36
		}
36
		}
37
		params.put("q", StringUtils.join(mandatoryQ, " "));
37
		params.put("q", StringUtils.join(mandatoryQ, " "));
38
		if (categoryId > 0) {
38
		if (categoryIds.size() > 0) {
39
			params.put("q", params.get("q") + " +filter(categoryId_i:" + categoryId + ")");
39
			params.put("q", params.get("q") + " +filter(categoryId_i:(" + StringUtils.join(categoryIds, " ") + "))");
40
		}
40
		}
41
		if (brands.size() > 0) {
41
		if (brands.size() > 0) {
42
			params.put("q", params.get("q") + " AND brand_ss:(" + StringUtils.join(brands, " ") + ")");
42
			params.put("q", params.get("q") + " AND brand_ss:(" + StringUtils.join(brands, " ") + ")");
43
		}
43
		}
44
		if (activeOnly) {
44
		if (activeOnly) {