Index: branches/pssGrails3/grails-app/controllers/com/lemanscorp/search/SearchController.groovy =================================================================== diff -u -r8884 -r8891 --- branches/pssGrails3/grails-app/controllers/com/lemanscorp/search/SearchController.groovy (.../SearchController.groovy) (revision 8884) +++ branches/pssGrails3/grails-app/controllers/com/lemanscorp/search/SearchController.groovy (.../SearchController.groovy) (revision 8891) @@ -7,23 +7,24 @@ class SearchController { - def solrService + def solrService - def index() { - redirect (action: 'usage') - } + def index() { + redirect(action: 'usage') + } - def usage() { + def usage() { - render '''q = query string
+ render '''q = query string
stage = facet stage
filter = contains your filter term rows= number of rows
offset= starting row
format= any value will return json; blank will return xml


- Example:
http://server:8080/search/?q=jacket&stage=1&filterField=brandName,category&filterValue=ICON,Beach&rows=10&offset=11&format=json + Example:
http://server:8080/search/?q=jacket&stage=1&filterField=brandName,category&filterValue=ICON, + Beach&rows=10&offset=11&format=json

@@ -33,48 +34,49 @@ format= any value will return json blank will return xml


Example:
http://server:8080/autoSuggest/?q=jacket&limit=10&format=json ''' - } + } - def directSolr() { - params.q = unMaskAmpersand(params.q) - if (!params.outfields) { params.outfields = 'partNumber' } - def result = solrService.programCriteriaQuery(params) - render(text: result, contentType: 'text/xml', encoding: 'ISO-8859-1') - } + def directSolr() { + params.q = unMaskAmpersand(params.q) + params.outfields = params.outfields ?: 'partNumber' + def result = solrService.programCriteriaQuery(params) + render(text: result, contentType: 'text/xml', encoding: 'ISO-8859-1') + } - def solr() { - params.q = unMaskAmpersand(params.q) - def result = solrService.runQuery(params) - if (params.q != null) { - def searchTermLogger = LogFactory.getLog('searchTermsLogger') - searchTermLogger.info('X-UUID:"' + request.getHeader('X-UUID') + '" searchTerm:"' + result.header.q + '" results:"' + result.header.total + '" index:"' + result.header.renderers[0] + '"' ) - } - withFormat { - json { render result as JSON } - xml { render(text: result as XML, contentType: 'text/xml', encoding: 'ISO-8859-1') } - } - } + def solr() { + params.q = unMaskAmpersand(params.q) + def result = solrService.runQuery(params) + if (params.q != null) { + def searchTermLogger = LogFactory.getLog('searchTermsLogger') + searchTermLogger.info('X-UUID:"' + request.getHeader('X-UUID') + '" searchTerm:"' + result.header.q + '" results:"' + result + .header.total + '" index:"' + result.header.renderers[0] + '"') + } + withFormat { + json { render result as JSON } + xml { render(text: result as XML, contentType: 'text/xml', encoding: 'ISO-8859-1') } + } + } - def autoSuggest() { - def result - if (params.q && params.q != '') { - result = solrService.runAutoSuggestQuery(params) - withFormat { - json { render result as JSON } - xml { render(text: result as XML, contentType: 'text/xml', encoding: 'ISO-8859-1') } - } - } - } + def autoSuggest() { + def result + if (params.q && params.q != '') { + result = solrService.runAutoSuggestQuery(params) + withFormat { + json { render result as JSON } + xml { render(text: result as XML, contentType: 'text/xml', encoding: 'ISO-8859-1') } + } + } + } - /** - * This a temp. fix for the issue in Camel to process '&'(ambersand), - * In Camel before calling Solr search service & symbols will be replace with '`' Symbole - * this code is to revert the change and replace '`' with '&'. - * Once Camel is upgraded 3.0 version, this bypass can be removed. - * @param searchTerm - * @return - */ - String unMaskAmpersand(String searchTerm) { - searchTerm?.replaceAll('`', '&') - } + /** + * This a temp. fix for the issue in Camel to process '&'(ambersand), + * In Camel before calling Solr search service & symbols will be replace with '`' Symbole + * this code is to revert the change and replace '`' with '&'. + * Once Camel is upgraded 3.0 version, this bypass can be removed. + * @param searchTerm + * @return + */ + String unMaskAmpersand(String searchTerm) { + searchTerm?.replaceAll('`', '&') + } }