Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-1959

SolrJ GET operation does not send correct encoding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4.1, 3.2
    • None
    • clients - java
    • None

    Description

      The SolrJ query operation fails to set the character encoding when doing a GET. It works when doing a POST.

      The problem is that URLs are urlencoded with UTF-8 but the Content-type: header is not set. I tested it with "Content-Type:text/plain;charset=utf-8" and that worked. The Content-type header encoding defaults to ISO 8859-1.

      The result is that SolrJ queries fail for any search with a character above 127. The work around is to use a POST query instead of a GET. I have not searched for other places. So, change:

      QueryResponse qr = CommonsHttpSolrServer.query(query);
      

      to:

      QueryResponse qr = CommonsHttpSolrServer.query(query, SolrRequest.METHOD.POST);
      

      One quirk of this behavior is that url-bashing a query string with an ISO 8859-1 character (like an umlaut) works in a browser, but fails in a SolrJ request.. It also searches correctly from the admin/index.jsp and admin/form.jsp pages, because they set the content-type in the FORM declaration.

      Attachments

        1. SOLR-1959.patch
          0.7 kB
          Lance Norskog

        Activity

          People

            Unassigned Unassigned
            lancenorskog Lance Norskog
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: