Subversion Repositories SmartDukaan

Rev

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

Rev 3223 Rev 3246
Line 74... Line 74...
74
	 */
74
	 */
75
	public SolrSearchService(String query, String[] facetqueries, String[] facetDefinitionIDs, long start, long rows,  Double minPrice, Double maxPrice, long categoryId, String sortOrder) {
75
	public SolrSearchService(String query, String[] facetqueries, String[] facetDefinitionIDs, long start, long rows,  Double minPrice, Double maxPrice, long categoryId, String sortOrder) {
76
		
76
		
77
		this.xpath = XPathFactory.newInstance().newXPath();
77
		this.xpath = XPathFactory.newInstance().newXPath();
78
		
78
		
79
    	// if multiple words are given, it should do AND for all of them
-
 
80
		query = query.trim().replaceAll("\\s+", " ");
79
		query = query.trim().replaceAll("\\s+", " ");
81
    	if(query.contains(" ")){
-
 
82
    		String[] tokens = query.split("\\s+");
-
 
83
    		query = tokens[0];
-
 
84
    		for(int i = 1; i < tokens.length; i++){
-
 
85
    			query = query + " AND " + tokens[i];
-
 
86
    		}
-
 
87
    	}
-
 
88
    	log.info("query=" + query);
80
    	log.info("query=" + query);
89
    	
81
    	
90
		String uri = SOLR_URL + "?wt=xml&q=" + query;
82
		String uri = SOLR_URL + "?wt=xml&q=" + query;
91
		
83
		
92
		uri += "&stats=on&stats.field=F_50002";
84
		uri += "&stats=on&stats.field=F_50002";
Line 156... Line 148...
156
		}
148
		}
157
 
149
 
158
		return tempFacets;
150
		return tempFacets;
159
	}
151
	}
160
	
152
	
161
/*
-
 
162
	int sumOfFacetCounts = 0;
-
 
163
	for(String facetValueName : facetMap.get(facet).keySet()){
-
 
164
		if(facetMap.get(facet).get(facetValueName) == 0 || facetMap.get(facet).get(facetValueName) == numberOfResults){
-
 
165
			tempFacets.get(facet).remove(facetValueName);
-
 
166
			// FIXME
-
 
167
			/
-
 
168
			HashMap<String, Integer> tmp = tempFacets.get(facet);
-
 
169
			tmp.remove(facetValueName);
-
 
170
			tempFacets.put(facet, tmp);
-
 
171
			/
-
 
172
		}else{
-
 
173
			sumOfFacetCounts += facetMap.get(facet).get(facetValueName);
-
 
174
		}
-
 
175
	}
-
 
176
	if(sumOfFacetCounts < numberOfResults*PERCENTAGE_OF_TOTAL_RESULTS/100){
-
 
177
		tempFacets.remove(facet);
-
 
178
	}
-
 
179
}
-
 
180
 
-
 
181
*/
-
 
182
	public HashMap<String,Integer> getFacetDetails(String facetName){
153
	public HashMap<String,Integer> getFacetDetails(String facetName){
183
		if(facetMap != null){
154
		if(facetMap != null){
184
			return facetMap.get(facetName);
155
			return facetMap.get(facetName);
185
		}else{
156
		}else{
186
			return null;
157
			return null;
Line 505... Line 476...
505
		
476
		
506
		String[] values = new String[nodes.getLength()];
477
		String[] values = new String[nodes.getLength()];
507
		for(int i=0; i<nodes.getLength(); i++) {
478
		for(int i=0; i<nodes.getLength(); i++) {
508
			Node node = nodes.item(i);
479
			Node node = nodes.item(i);
509
			values[i] = node.getTextContent();
480
			values[i] = node.getTextContent();
510
//			log.info("Facets Counts  " + values[i]);
-
 
511
 		}
481
 		}
512
		
482
		
513
		return values;
483
		return values;
514
	}
484
	}
515
 
485