Subversion Repositories SmartDukaan

Rev

Rev 354 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 354 Rev 517
Line 112... Line 112...
112
//					}else{
112
//					}else{
113
//						this.minPrice = StringUtils.split(facetqueries[i], ":")[1];
113
//						this.minPrice = StringUtils.split(facetqueries[i], ":")[1];
114
//					}
114
//					}
115
//					
115
//					
116
//				}else{
116
//				}else{
117
				uri += "&fq=" + facetqueries[i];
117
				uri += "&fq=" + facetqueries[i] + "";
118
//				}
118
//				}
119
			}
119
			}
120
		}
120
		}
121
//		uri += "&fq=F_50002:[" + this.minPrice + " TO " + this.maxPrice + "]";
121
//		uri += "&fq=F_50002:[" + this.minPrice + " TO " + this.maxPrice + "]";
122
		uri += "&fl=ID,Name&facet=true&rows=" + NUMBER_OF_ROWS;
122
		uri += "&fl=ID,Name&facet=true&rows=" + NUMBER_OF_ROWS;
Line 130... Line 130...
130
		this.inputSource = new InputSource(uri);
130
		this.inputSource = new InputSource(uri);
131
		this.facetMap = new TreeMap<String, HashMap<String,Integer>>(getFacetMap());
131
		this.facetMap = new TreeMap<String, HashMap<String,Integer>>(getFacetMap());
132
	}
132
	}
133
	
133
	
134
	public static void main(String[] args){
134
	public static void main(String[] args){
-
 
135
		/*
135
    	// Hard coded for now
136
    	// Hard coded for now
136
    	String[] facetDefIDs = new String[] {"F_50001", "F_50002", "F_50003", "F_50004", "F_50005", "F_50006", "F_50007", "F_50008", "F_50009"};
137
    	String[] facetDefIDs = new String[] {"F_50001", "F_50002", "F_50003", "F_50004", "F_50005", "F_50006", "F_50007", "F_50008", "F_50009"};
137
    	
138
 
138
    	// Hard-coded for now
139
    	// Hard-coded for now
139
    	String[] facetLabels = new String[] {
140
    	String[] facetLabels = new String[] {
140
	    	"Brand", "Price","Form Factor", "Carry In Pocket", "Cellular Technologies", 
141
	    	"Brand", "Price","Form Factor", "Carry In Pocket", "Cellular Technologies", 
141
	    	"Data Connectivity", "Camera Resolution", "Built-in Memory", 
142
	    	"Data Connectivity", "Camera Resolution", "Built-in Memory", 
142
	    	"Talk time"
143
	    	"Talk time"
143
    	};
144
    	};
144
 
145
 
-
 
146
		 */
-
 
147
    	String[] facetDefIDs = new String[] {"Category","F_50002","F_50001",  "F_50006", "F_50007" };
-
 
148
    	String[] facetLabels = new String[] {"Category","Price", "Brand", "Data Connectivity", "Camera Resolution"	};
-
 
149
 
-
 
150
    	
145
//    	HashMap<String,String> fqrys = new HashMap<String, String>();
151
//    	HashMap<String,String> fqrys = new HashMap<String, String>();
146
    	String[] fqrys = {};
152
    	String[] fqrys = {};
147
//    	fqrys.put("minPrice", "10");
153
//    	fqrys.put("minPrice", "10");
148
		SolrSearchService search = new SolrSearchService("nokia", fqrys, facetDefIDs);
154
		SolrSearchService search = new SolrSearchService("nokia", fqrys, facetDefIDs);
149
    	
155
    	
Line 167... Line 173...
167
 
173
 
168
	
174
	
169
	public TreeMap<String,HashMap<String,Integer>> removeUnwantedFacets(TreeMap<String,HashMap<String,Integer>> facetMap, int numberOfResults){
175
	public TreeMap<String,HashMap<String,Integer>> removeUnwantedFacets(TreeMap<String,HashMap<String,Integer>> facetMap, int numberOfResults){
170
		TreeMap<String,HashMap<String,Integer>> tempFacets = new TreeMap<String, HashMap<String,Integer>>(facetMap); 
176
		TreeMap<String,HashMap<String,Integer>> tempFacets = new TreeMap<String, HashMap<String,Integer>>(facetMap); 
171
		for(String facet : facetMap.keySet()){
177
		for(String facet : facetMap.keySet()){
172
			if(facetMap.get(facet).size() == 1){
178
			if(facetMap.get(facet).size() <= 1){
173
				// FIXME  
179
				// FIXME  
174
				//tempFacets.remove(facet);
180
				tempFacets.remove(facet);
175
			}else{
181
			}else{
176
				int sumOfFacetCounts = 0;
182
				int sumOfFacetCounts = 0;
177
				for(String facetValueName : facetMap.get(facet).keySet()){
183
				for(String facetValueName : facetMap.get(facet).keySet()){
178
					if(facetMap.get(facet).get(facetValueName) == 0){
184
					if(facetMap.get(facet).get(facetValueName) == 0 || facetMap.get(facet).get(facetValueName) == numberOfResults){
179
						tempFacets.get(facet).remove(facetValueName);
185
						tempFacets.get(facet).remove(facetValueName);
-
 
186
						/*
-
 
187
						HashMap<String, Integer> tmp = tempFacets.get(facet);
-
 
188
						tmp.remove(facetValueName);
-
 
189
						tempFacets.put(facet, tmp);
-
 
190
						*/
180
					}else{
191
					}else{
181
						sumOfFacetCounts += facetMap.get(facet).get(facetValueName);
192
						sumOfFacetCounts += facetMap.get(facet).get(facetValueName);
182
					}
193
					}
183
				}
194
				}
184
				if(sumOfFacetCounts < numberOfResults*PERCENTAGE_OF_TOTAL_RESULTS/100){
195
				if(sumOfFacetCounts < numberOfResults*PERCENTAGE_OF_TOTAL_RESULTS/100){
Line 233... Line 244...
233
			}
244
			}
234
			//System.out.println(facetName +":"+ facetValueCountMap);
245
			//System.out.println(facetName +":"+ facetValueCountMap);
235
			facetMap.put(facetName, facetValueCountMap);
246
			facetMap.put(facetName, facetValueCountMap);
236
			}
247
			}
237
		System.out.println(facetMap);
248
		System.out.println(facetMap);
-
 
249
		
238
		int numberOfResults = 10;
250
		int numberOfResults = 10;
-
 
251
		
239
		facetMap = removeUnwantedFacets(facetMap, numberOfResults);
252
		facetMap = removeUnwantedFacets(facetMap, numberOfResults);
240
		System.out.println(facetMap);
253
		System.out.println(facetMap);
241
		return facetMap;
254
		return facetMap;
242
		}
255
		}
243
	
256