Subversion Repositories SmartDukaan

Rev

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

Rev 27325 Rev 27601
Line 24... Line 24...
24
	@Value("${new.solr.url}")
24
	@Value("${new.solr.url}")
25
	private String solrUrl;
25
	private String solrUrl;
26
	
26
	
27
	@Autowired
27
	@Autowired
28
	private RestClient restClient;
28
	private RestClient restClient;
29
	public String getContent(String queryTerm) throws Exception {
29
	public String getContent(String queryTerm, int categoryId, List<String> brands) 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) {
-
 
39
			params.put("q", params.get("q") + " +filter(categoryId_i:" + categoryId + ")");
-
 
40
		}
-
 
41
		if(brands.size()>0) {
-
 
42
			params.put("q", params.get("q") + " AND brand_ss:(" + StringUtils.join(brands, " ") + ")");
-
 
43
		}
38
		params.put("fl", "*");
44
		params.put("fl", "*");
39
		if (queryTerm == null) {
45
		if (queryTerm == null) {
40
			params.put("sort", "create_s desc");
46
			params.put("sort", "create_s desc");
41
		}
47
		}
42
		params.put("start", String.valueOf(0));
48
		params.put("start", String.valueOf(0));