public String highlightQuery(QueryInfo info, String fieldName, String text) {
    String result = "";
    //		String fieldNameOriginal=fieldName;
    //		String textOriginal=text;
    //		String attributeName="";
    try {
      EFOExpandableQueryInfo queryInfo = null;
      //			logger.debug("text->{}", text);
      //			logger.debug("fieldName->{}", fieldName);
      if (info instanceof EFOExpandableQueryInfo) {
        queryInfo = (EFOExpandableQueryInfo) info;
      }

      //			if(fieldName.startsWith("attributes:")){
      //				fieldName="attributes";
      //				attributeName=fieldNameOriginal.replace("attributes:", "");
      //				text=attributeName+"="+text;
      //
      //			}

      if (null == queryInfo) {
        result = doHighlightQuery(info.getQuery(), fieldName, text, HIT_OPEN_MARK, HIT_CLOSE_MARK);
      } else {
        result =
            doHighlightQuery(
                queryInfo.getOriginalQuery(), fieldName, text, HIT_OPEN_MARK, HIT_CLOSE_MARK);
        result =
            doHighlightQuery(
                queryInfo.getSynonymPartQuery(), fieldName, result, SYN_OPEN_MARK, SYN_CLOSE_MARK);
        result =
            doHighlightQuery(
                queryInfo.getEfoExpansionPartQuery(),
                fieldName,
                result,
                EFO_OPEN_MARK,
                EFO_CLOSE_MARK);

        result = EFO_AND_SYN_REGEX.replace(result, SYN_OPEN_MARK + "$1" + SYN_CLOSE_MARK);
        result = SYN_AND_HIT_REGEX.replace(result, HIT_OPEN_MARK + "$1" + HIT_CLOSE_MARK);
        result = EFO_AND_HIT_REGEX.replace(result, HIT_OPEN_MARK + "$1" + HIT_CLOSE_MARK);
      }

    } catch (Exception x) {
      logger.error("Caught an exception:", x);
    }
    // logger.debug("result->"+result);
    return result;
  }
  @Override
  protected void doRequest(
      HttpServletRequest request, HttpServletResponse response, RequestType requestType)
      throws ServletException, IOException {
    RegexHelper MATCH_URL_REGEX = new RegexHelper("/+(.+)", "i");
    RegexHelper TEST_HOST_IN_URL_REGEX = new RegexHelper("^http\\:/{2}([^/]+)/", "i");
    RegexHelper SQUARE_BRACKETS_REGEX = new RegexHelper("\\[\\]", "g");

    logRequest(logger, request, requestType);

    String url = MATCH_URL_REGEX.matchFirst(request.getPathInfo());
    url =
        url.replaceFirst(
            "http:/{1,2}", "http://"); // stupid hack as tomcat 6.0 removes second forward slash
    String queryString = request.getQueryString();

    if (0 < url.length()) {
      if (!TEST_HOST_IN_URL_REGEX.test(url)) { // no host here, will self
        url = "http://localhost:" + String.valueOf(request.getLocalPort()) + "/" + url;
      }
      logger.debug("Will access [{}]", url);

      GetMethod getMethod = new GetMethod(url);

      if (null != queryString) {
        queryString = SQUARE_BRACKETS_REGEX.replace(queryString, "%5B%5D");
        getMethod.setQueryString(queryString);
      }

      Enumeration requestHeaders = request.getHeaderNames();
      while (requestHeaders.hasMoreElements()) {
        String name = (String) requestHeaders.nextElement();
        String value = request.getHeader(name);
        if (null != value) {
          getMethod.setRequestHeader(name, value);
        }
      }

      try {
        httpClient.executeMethod(getMethod);

        int statusCode = getMethod.getStatusCode();
        long contentLength = getMethod.getResponseContentLength();
        logger.debug("Got response [{}], length [{}]", statusCode, contentLength);

        Header[] responseHeaders = getMethod.getResponseHeaders();
        for (Header responseHeader : responseHeaders) {
          String name = responseHeader.getName();
          String value = responseHeader.getValue();
          if (null != name
              && null != value
              && !(name.equals("Server")
                  || name.equals("Date")
                  || name.equals("Transfer-Encoding"))) {
            response.setHeader(responseHeader.getName(), responseHeader.getValue());
          }
        }

        if (200 != statusCode) {
          response.setStatus(statusCode);
        }

        InputStream inStream = getMethod.getResponseBodyAsStream();
        if (null != inStream) {
          BufferedReader in = new BufferedReader(new InputStreamReader(inStream));

          BufferedWriter out =
              new BufferedWriter(new OutputStreamWriter(response.getOutputStream()));

          CharBuffer buffer = CharBuffer.allocate(PROXY_BUFFER_SIZE);
          while (in.read(buffer) >= 0) {
            buffer.flip();
            out.append(buffer);
            buffer.clear();
          }

          in.close();
          out.close();
        }
      } catch (Exception x) {
        if (x.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
          logger.warn("Client aborted connection");
        } else {
          logger.error("Caught an exception:", x);
          response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, x.getMessage());
        }
      } finally {
        getMethod.releaseConnection();
      }
    }
  }