Subversion Repositories SmartDukaan

Rev

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

Rev 6942 Rev 6973
Line 6... Line 6...
6
import in.shop2020.serving.services.SolrSearchService;
6
import in.shop2020.serving.services.SolrSearchService;
7
import in.shop2020.serving.services.SpecialPageConfigurer;
7
import in.shop2020.serving.services.SpecialPageConfigurer;
8
import in.shop2020.serving.utils.Utils;
8
import in.shop2020.serving.utils.Utils;
9
import in.shop2020.thrift.clients.CatalogClient;
9
import in.shop2020.thrift.clients.CatalogClient;
10
 
10
 
11
import java.io.IOException;
-
 
12
import java.net.URLEncoder;
11
import java.net.URLEncoder;
13
import java.util.ArrayList;
12
import java.util.ArrayList;
14
import java.util.Arrays;
13
import java.util.Arrays;
15
import java.util.HashMap;
14
import java.util.HashMap;
16
import java.util.LinkedHashMap;
15
import java.util.LinkedHashMap;
Line 58... Line 57...
58
	private long windowSize = 20;
57
	private long windowSize = 20;
59
	private long page = 1;
58
	private long page = 1;
60
	private long totalResults;
59
	private long totalResults;
61
	private long beginIndex = 0;
60
	private long beginIndex = 0;
62
	private String url;
61
	private String url;
-
 
62
	private String sortOrder = "F_50030+desc";
-
 
63
	private String sortUrl = "?";
63
	private String priceUrl = "?";
64
	private String priceUrl = "?";
64
	private String uri;
65
	private String uri;
65
	
66
	
66
	public String index() throws Exception {
67
	public String index() throws Exception {
67
		uri = request.getRequestURI();
68
		uri = request.getRequestURI();
Line 87... Line 88...
87
    		log.info("fqrys=" + Arrays.toString(fqrys));
88
    		log.info("fqrys=" + Arrays.toString(fqrys));
88
	    	String filterUrl = "";
89
	    	String filterUrl = "";
89
	    	for(int i=0; i<fqrys.length; i++){
90
	    	for(int i=0; i<fqrys.length; i++){
90
	    		urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
91
	    		urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
91
	    		priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
92
	    		priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
-
 
93
	    		sortUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
92
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
94
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
93
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
95
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
94
	    		String facetLabel = facetLabels[arrList.indexOf(facetName)];
96
	    		String facetLabel = facetLabels[arrList.indexOf(facetName)];
95
	    		filterUrl = "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8"); 
97
	    		filterUrl = "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8"); 
96
	    		List<String> acrumb = Arrays.asList(facetValue, filterUrl);
98
	    		List<String> acrumb = Arrays.asList(facetValue, filterUrl);
Line 105... Line 107...
105
    	}
107
    	}
106
    	
108
    	
107
    	
109
    	
108
		url = urlCrumb;
110
		url = urlCrumb;
109
 
111
 
-
 
112
		if(this.request.getParameter("minPrice") != null){
-
 
113
			this.minPrice = (new Double(this.request.getParameter("minPrice")));
-
 
114
			url= url + "&minPrice=" + this.request.getParameter("minPrice");
-
 
115
		}
-
 
116
		
-
 
117
		if(this.request.getParameter("maxPrice") != null){
-
 
118
			this.maxPrice = (new Double(this.request.getParameter("maxPrice")));
-
 
119
			url= url + "&maxPrice=" + this.request.getParameter("maxPrice");
-
 
120
		}
-
 
121
		sortUrl = url;
-
 
122
		
110
    	if(this.request.getParameter("page") != null){
123
    	if(this.request.getParameter("page") != null){
111
    		this.page = Long.parseLong(this.request.getParameter("page"));
124
    		this.page = Long.parseLong(this.request.getParameter("page"));
112
    		this.beginIndex = this.windowSize * (this.page-1);
125
    		this.beginIndex = this.windowSize * (this.page-1);
113
    	}
126
    	}
114
 
127
 
115
    	if(this.request.getParameter("minPrice") != null){
128
    	if(request.getParameter("sort")!=null){
116
    		this.minPrice = (new Double(this.request.getParameter("minPrice")));
129
    		url= url + "&sort=" + "F_50028+asc" + this.request.getParameter("sort");
117
    		url= url + "&minPrice=" + this.request.getParameter("minPrice");
130
    		sortOrder = this.request.getParameter("sort");
-
 
131
    	} else {
-
 
132
    		url = url + "&sort=" + this.sortOrder;
118
    	}
133
    	}
119
 
134
 
120
    	if(this.request.getParameter("maxPrice") != null){
-
 
121
    		this.maxPrice = (new Double(this.request.getParameter("maxPrice")));
-
 
122
    		url= url + "&maxPrice=" + this.request.getParameter("maxPrice");
-
 
123
    	}
-
 
124
    	
135
    	
125
    	if (type!=0) {
136
    	if (type!=0) {
126
    		query = "*&fq=F_50029:"+query;
137
    		query = "*&fq=F_50029:"+query;
127
    	}
138
    	}
128
    		
139
    		
129
    	String sortOrder = "F_50028+asc,F_50030+desc";
-
 
130
    	
140
    	
131
    	SolrSearchService search = new SolrSearchService(query, fqrys, Utils.facetDefIDs, (page-1)*windowSize, windowSize, minPrice, maxPrice, 10000, sortOrder, sourceId);
141
    	SolrSearchService search = new SolrSearchService(query, fqrys, Utils.facetDefIDs, (page-1)*windowSize, windowSize, minPrice, maxPrice, 10000, "F_50028+asc," + sortOrder, sourceId);
132
    	this.results =  search.getResultMap(); 
142
    	this.results =  search.getResultMap(); 
133
    	this.dynamicSearchMap = search.getDynamicPriceMap();
143
    	this.dynamicSearchMap = search.getDynamicPriceMap();
134
    	setFacet(Arrays.asList(fqrys), search);
144
    	setFacet(Arrays.asList(fqrys), search);
135
 
145
 
136
 
146
 
Line 299... Line 309...
299
    		return "{}";
309
    		return "{}";
300
    	} else {
310
    	} else {
301
    		return new Gson().toJson(this.dynamicSearchMap);
311
    		return new Gson().toJson(this.dynamicSearchMap);
302
    	}
312
    	}
303
    }
313
    }
-
 
314
	
-
 
315
	public String getSortOrder(){
-
 
316
		return this.sortOrder;
-
 
317
	}
-
 
318
	
-
 
319
	public String getSortUrl(){
-
 
320
		return this.sortUrl;
-
 
321
	}
-
 
322
 
-
 
323
	public String getUri(){
-
 
324
		return this.uri;
-
 
325
	}
304
}
326
}