views:

191

answers:

1

I have queries that I am running against out solr index that sometimes have very long query parameters, I get errors when i run these queries, which i assume are do to the limit of a GET query parameters.

Here is the method I use to query (JSON), this is to show I am using the Http Extensions (the client i use is a thin wrapper for HttpClient) not an end to end solution. 90% of the queries run fine, it is just when the params are large i get the 500 error from solr. I have read somewhere you can use POSt's when doing the select command but have not found examples of how to do it. Any help would be fantastic!

    public string GetJson(HttpQueryString qs)
    {
        using (var client = new DAC.US.Web.XmlHttpServiceClient(this.Uri))
        {
            client.Client.DefaultHeaders.Authorization = new Microsoft.Http.Headers.Credential("Basic", DAC.US.Encryption.Hash.WebServiceCredintials);
            qs.Add("wt", "json");

            if (!String.IsNullOrEmpty(this.Version))
                qs.Add("version", this.Version);

            using (var response = client.Get(new Uri(@"select/", UriKind.Relative), qs))
            {
                return response.Content.ReadAsString();
            }
        }
    }
+1  A: 
  1. Don't assume. Check the Solr log to confirm the reason of this error.
  2. /select accepts POST requests without issues. You can try this with curl:

    curl -d "q=*:*&rows=1" http://localhost:8983/solr/select
    

    I can't comment on XmlHttpServiceClient as it seems to be some proprietary code, but see this page for an example of POSTing using HttpWebRequest.

BTW: there are .net libraries that implement communicating with Solr, no need to roll your own unless you have some very weird requirements.

Mauricio Scheffer
I am using not using the HttpWebRequest, technically but am using a thin wrapper for the Microsoft.Http library. I have fairly dodd requirements, which i found more difficult to implement with SolrNet and such. I guess my main question is this, is the POST param data equal to what the querystring looks like for the GET. From your curl example it seems the post takes 1 param...
RyanFetz
@RyanFetz: yes, the POST data is the same as the querystring.
Mauricio Scheffer
@RyanFetz: BTW I'm interested in hearing about those difficulties with SolrNet :-)
Mauricio Scheffer