Subversion Repositories SmartDukaan

Rev

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

Rev 21290 Rev 21291
Line 53... Line 53...
53
		String jsonString = null;
53
		String jsonString = null;
54
		try {
54
		try {
55
			jsonString = solrService.getSearchResults(search_text.trim(), offset);
55
			jsonString = solrService.getSearchResults(search_text.trim(), offset);
56
		} catch (URISyntaxException | IOException e) {
56
		} catch (URISyntaxException | IOException e) {
57
			logger.error("Error while gettting search results from solr",e);
57
			logger.error("Error while gettting search results from solr",e);
58
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), ProfitMandiConstants.URL_SOLR_SEARCH , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, new JsonArray().toString());
58
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), ProfitMandiConstants.URL_SOLR_SEARCH , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, (String) new JsonArray().toString());
59
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
59
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
60
		}
60
		}
61
		JsonArray result_json = Json.parse(jsonString).asObject().get("response").asObject().get("docs").asArray();
61
		JsonArray result_json = Json.parse(jsonString).asObject().get("response").asObject().get("docs").asArray();
62
		for (JsonValue j : result_json ){
62
		for (JsonValue j : result_json ){
63
			j.asObject().add("productUrl", j.asObject().get("ids").asArray().get(0)+"/"+j.asObject().get("id").asString());
63
			j.asObject().add("productUrl", j.asObject().get("ids").asArray().get(0)+"/"+j.asObject().get("id").asString());
64
		}
64
		}
65
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), ProfitMandiConstants.URL_SOLR_SEARCH , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, result_json.toString());
65
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), ProfitMandiConstants.URL_SOLR_SEARCH , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, (String)result_json.toString());
66
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
66
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
67
	}
67
	}
68
 
68
 
69
 
69
 
70
	@RequestMapping(value = ProfitMandiConstants.URL_SOLR_SUGGESTION, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
70
	@RequestMapping(value = ProfitMandiConstants.URL_SOLR_SUGGESTION, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)