| Line 19... |
Line 19... |
| 19 |
|
19 |
|
| 20 |
private static final Logger logger=LoggerFactory.getLogger(SolrService.class);
|
20 |
private static final Logger logger=LoggerFactory.getLogger(SolrService.class);
|
| 21 |
|
21 |
|
| 22 |
@Value("${solr.url}")
|
22 |
@Value("${solr.url}")
|
| 23 |
private String SOLR_URL;
|
23 |
private String SOLR_URL;
|
| 24 |
//private static final String SOLR_URL="http://192.168.158.89:8983/solr/collection1/select";
|
- |
|
| 25 |
private static final String limit ="20";
|
24 |
private static final String limit ="20";
|
| 26 |
private static final String groupLimit = "10";
|
25 |
private static final String groupLimit = "10";
|
| 27 |
private static final String autoSuggestField = "title,subCategoryId,category_id,category,subCategory,score";
|
26 |
private static final String autoSuggestField = "title,subCategoryId,category_id,category,subCategory,score";
|
| 28 |
private static final String searchResultsField = "title,skuBundleId,id,thumbnail,ids";
|
27 |
private static final String searchResultsField = "title,skuBundleId,id,thumbnail,ids";
|
| 29 |
private static final String outputFormat = "json";
|
28 |
private static final String outputFormat = "json";
|
| 30 |
|
29 |
|
| 31 |
|
30 |
|
| 32 |
|
31 |
|
| 33 |
public String getSuggestions(String search_text) throws URISyntaxException, IOException{
|
32 |
public String getSuggestions(String search_text) throws URISyntaxException, IOException{
|
| 34 |
|
33 |
|
| 35 |
logger.info("Solr url "+SOLR_URL);
|
- |
|
| 36 |
URIBuilder autoSuggestUrl = new URIBuilder(SOLR_URL);
|
34 |
URIBuilder autoSuggestUrl = new URIBuilder(SOLR_URL);
|
| 37 |
autoSuggestUrl.addParameter("fl", autoSuggestField); //Fields to choose
|
35 |
autoSuggestUrl.addParameter("fl", autoSuggestField); //Fields to choose
|
| 38 |
autoSuggestUrl.addParameter("wt", outputFormat); //Output format
|
36 |
autoSuggestUrl.addParameter("wt", outputFormat); //Output format
|
| 39 |
autoSuggestUrl.addParameter("group", "true"); //group data
|
37 |
autoSuggestUrl.addParameter("group", "true"); //group data
|
| 40 |
autoSuggestUrl.addParameter("group.query", "category_id:3"); //group by category
|
38 |
autoSuggestUrl.addParameter("group.query", "category_id:3"); //group by category
|
| Line 54... |
Line 52... |
| 54 |
}
|
52 |
}
|
| 55 |
return jsonString;
|
53 |
return jsonString;
|
| 56 |
}
|
54 |
}
|
| 57 |
|
55 |
|
| 58 |
public String getSearchResults(String search_text, int offset) throws URISyntaxException, IOException{
|
56 |
public String getSearchResults(String search_text, int offset) throws URISyntaxException, IOException{
|
| 59 |
logger.info("Solr url "+SOLR_URL);
|
- |
|
| - |
|
57 |
|
| 60 |
URIBuilder generalSearchUrl = new URIBuilder(SOLR_URL);
|
58 |
URIBuilder generalSearchUrl = new URIBuilder(SOLR_URL);
|
| 61 |
generalSearchUrl.addParameter("q", search_text);
|
59 |
generalSearchUrl.addParameter("q", search_text);
|
| 62 |
generalSearchUrl.addParameter("fl", searchResultsField); //Fields to choose
|
60 |
generalSearchUrl.addParameter("fl", searchResultsField); //Fields to choose
|
| 63 |
generalSearchUrl.addParameter("wt", outputFormat); //Output format
|
61 |
generalSearchUrl.addParameter("wt", outputFormat); //Output format
|
| 64 |
generalSearchUrl.addParameter("rows", limit); //limit
|
62 |
generalSearchUrl.addParameter("rows", limit); //limit
|