@RequestMapping(method = RequestMethod.POST)
 @ResponseBody
 public List<Document> searchConnection(
     @ModelAttribute final ConnectionSearchRequest searchRequest) {
   final SearchResult searchResult =
       searchService.search(
           asList(Index.WATERTAX.toString()),
           asList(IndexType.CONNECTIONSEARCH.toString()),
           searchRequest.searchQuery(),
           searchRequest.searchFilters(),
           Sort.NULL,
           Page.NULL);
   return searchResult.getDocuments();
 }
  @Override
  public JsonElement serialize(
      final SearchResult searchResult, final Type type, final JsonSerializationContext jsc) {
    final JsonArray jsonArray = new JsonArray();
    HashMap<String, Object> clausesMap = new HashMap<String, Object>(0);
    HashMap<String, Object> searchableMap = new HashMap<String, Object>(0);
    for (final Document document : searchResult.getDocuments()) {
      final JsonObject jsonObject = new JsonObject();
      clausesMap = (HashMap) document.getResource().get("clauses");
      jsonObject.addProperty("consumercode", clausesMap.get("consumercode").toString());
      jsonObject.addProperty("assessmentnumber", clausesMap.get("propertyid").toString());
      jsonObject.addProperty(
          "applicationtype", clausesMap.get("applicationcode").toString().toLowerCase());
      jsonObject.addProperty("usagetype", clausesMap.get("usage").toString().toLowerCase());
      jsonObject.addProperty("mobilenumber", clausesMap.get("mobilenumber").toString());
      jsonObject.addProperty("zone", clausesMap.get("zone").toString());
      jsonObject.addProperty("ward", clausesMap.get("ward").toString());
      jsonObject.addProperty("totaldue", Integer.toString((Integer) clausesMap.get("totaldue")));
      jsonObject.addProperty(
          "currentdue", Integer.toString((Integer) clausesMap.get("waterTaxDue")));
      jsonObject.addProperty(
          "connectiontype", clausesMap.get("connectiontype").toString().toLowerCase());

      searchableMap = (HashMap) document.getResource().get("searchable");
      jsonObject.addProperty("consumername", searchableMap.get("consumername").toString());
      jsonObject.addProperty(
          "locality",
          searchableMap.get("locality") != null ? searchableMap.get("locality").toString() : "");
      jsonObject.addProperty(
          "pincode", searchableMap.get("PIN") != null ? searchableMap.get("PIN").toString() : "");
      jsonArray.add(jsonObject);
    }
    return jsonArray;
  }