[ 
https://issues.apache.org/jira/browse/SOLR-5971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15018164#comment-15018164
 ] 

Ishan Chattopadhyaya commented on SOLR-5971:
--------------------------------------------

We use the {{ClientUtils.toQueryString()}}.

{noformat}
  public static String toQueryString( SolrParams params, boolean xml ) {
    StringBuilder sb = new StringBuilder(128);
    try {
      String amp = xml ? "&" : "&";
      boolean first=true;
      Iterator<String> names = params.getParameterNamesIterator();
      while( names.hasNext() ) {
        String key = names.next();
        String[] valarr = params.getParams( key );
        if( valarr == null ) {
          sb.append( first?"?":amp );
          sb.append(key);
          first=false;
        }
        else {
          for (String val : valarr) {
            sb.append( first? "?":amp );
            sb.append(key);
            if( val != null ) {
              sb.append('=');
              sb.append( URLEncoder.encode( val, StandardCharsets.UTF_8.name() 
) );
            }
            first=false;
          }
        }
      }
    }
    catch (IOException e) {throw new RuntimeException(e);}  // can't happen
    return sb.toString();
  }
{noformat}

Do you know how to use the HttpClient to build the query string?

> 'Illegal character in query' when proxying request
> --------------------------------------------------
>
>                 Key: SOLR-5971
>                 URL: https://issues.apache.org/jira/browse/SOLR-5971
>             Project: Solr
>          Issue Type: Bug
>          Components: SolrCloud
>    Affects Versions: 4.7.1
>         Environment: Debian Wheezy, Java(TM) SE Runtime Environment (build 
> 1.6.0_26-b03)
>            Reporter: Eric Bus
>            Priority: Blocker
>              Labels: characters, exception, invalid, proxy, query, solrcloud
>             Fix For: 5.5, 6.0
>
>         Attachments: SOLR-5971.patch, SOLR-5971.patch, SOLR-5971.patch
>
>
> My cluster contains 3 Solr instances. I have a collection consisting of one 
> shard with 2 replica's. So one node in the cluster does not have a replicate 
> of the shard.
> The following query works when I query one of the two replica nodes:
> http://X.X.X.X:8080/solr/collection/select/?facet=true&facet.field={!ex%3Dfilters,filter1340+key%3Dfacet1340Values}string_months_month&facet=true&q=*:*
> But when I query the node without the replica, I get;
> {msg=Illegal character in query at index 78: 
> http://X.X.X.X:8080/solr/collection/select/?facet=true&facet.field={!ex%3Dfilters,filter1340+key%3Dfacet1340Values}string_months_month&facet=true&q=*:*,trace=java.lang.IllegalArgumentException
>       at java.net.URI.create(URI.java:842)
>       at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:69)
>       at 
> org.apache.solr.servlet.SolrDispatchFilter.remoteQuery(SolrDispatchFilter.java:527)
>       at 
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:340)
>       at 
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:217)
>       at 
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
>       at 
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
>       at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>       at 
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
>       at 
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>       at 
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>       at 
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>       at 
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>       at 
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>       at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>       at 
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
>       at 
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>       at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>       at org.eclipse.jetty.server.Server.handle(Server.java:368)
>       at 
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
>       at 
> org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
>       at 
> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
>       at 
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
>       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
>       at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>       at 
> org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
>       at 
> org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
>       at 
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>       at 
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>       at java.lang.Thread.run(Thread.java:662)
> Without the facet.field attribute, it works fine on all the nodes.
> Is this some kind of double escaping when proxying the request?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to