Query: URl too long

461 views
Skip to first unread message

Frederico

unread,
Jul 12, 2010, 10:05:35 AM7/12/10
to SolrNet
Hi all,

i'm facing a problem when using a query with about 100 000 chars.

When creating the URL object for the request i get an "URl too long"
exception. As far as i understand the URI has a maximum of 65000
chars.

I posted these problem on SOLR mailing and someone redirected me here
and said that the problem could be solved changing the http method
from GET to POST.

Anyone got this problem already? How can i reduce the Url string
changing the method to POST?

Thank you,
Frederico

Mauricio Scheffer

unread,
Jul 12, 2010, 11:07:09 AM7/12/10
to SolrNet
Yes, as I was saying in the solr-user mailing list, you can switch to
POST in queries by implementing a ISolrConnection decorator. In the
Get() method you'd build a POST request instead of the standard GET.

Cheers,
Mauricio

Frederico

unread,
Jul 12, 2010, 12:16:33 PM7/12/10
to SolrNet
Hi,

where can i get some info on where to start?
Isn't the POST request need the URI string also?

Thanks for the help Mauricio.


On Jul 12, 4:07 pm, Mauricio Scheffer <mauricioschef...@gmail.com>
wrote:

Mauricio Scheffer

unread,
Jul 12, 2010, 1:08:41 PM7/12/10
to sol...@googlegroups.com
Take a look at the default implementation of SolrConnection: http://github.com/mausch/SolrNet/blob/master/SolrNet/Impl/SolrConnection.cs

You can implement a decorator over SolrConnection, which for the Get() method would perform a POST request (similarly to the Post() method) instead of the default GET request.

If you're using the built-in default container you can use this new implementation like this:

Startup.Init<MyDocument>(new MyPostQueryConnection(new SolrConnection("http://localhost:8983/solr")));

--
Mauricio

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/solrnet?hl=en.


Frederico

unread,
Jul 13, 2010, 5:52:08 AM7/13/10
to SolrNet
Hi ,
i'm just testing manually the existing "Post" method (on
solrConnection) before the implementation, just to check if it works.

I'm using the following parameters:

relativeUrl: "/select/"
s: "fieldname: fieldvalue1 OR fieldname: fieldvalue2 OR fieldname:
fieldvalue3"

but i'm getting "Unable to read data from the transport connection: An
established connection was aborted by the software in your host
machine".
I disabled all firewalls and antivirus software from my computer and
it stills returns the error.

What parameters should i pass to this post method?




On Jul 12, 6:08 pm, Mauricio Scheffer <mauricioschef...@gmail.com>
wrote:
> Take a look at the default implementation of SolrConnection:http://github.com/mausch/SolrNet/blob/master/SolrNet/Impl/SolrConnect...
>
> You can implement a decorator over SolrConnection, which for the Get()
> method would perform a POST request (similarly to the Post() method) instead
> of the default GET request.
>
> If you're using the built-in default container you can use this new
> implementation like this:
>
> Startup.Init<MyDocument>(new MyPostQueryConnection(new SolrConnection("http://localhost:8983/solr")));
>
> --
> Mauricio
>
> > solrnet+u...@googlegroups.com<solrnet%2Bunsu...@googlegroups.com>
> > .

Mauricio Scheffer

unread,
Jul 13, 2010, 11:07:18 AM7/13/10
to sol...@googlegroups.com
When POSTing to the server you have to serialize the parameters just as you would serialize them for a querystring, e.g. the string you POST would be:

q=fieldname%3Afieldvalue1+OR+fieldname%3Afieldvalue2+OR+fieldname%3Afieldvalue3

Whenever you see some weird error on the client, always check the Solr log for the real error reason.

--
Mauricio

To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.

Mauricio Scheffer

unread,
Jul 26, 2010, 9:48:57 AM7/26/10
to SolrNet
http://code.google.com/p/solrnet/issues/detail?id=112

Frederico, did you finally manage to implement this? Would you
consider contributing it to the project?

Cheers,
Mauricio

On Jul 13, 12:07 pm, Mauricio Scheffer <mauricioschef...@gmail.com>
wrote:
> When POSTing to the server you have to serialize the parameters just as you
> would serialize them for a querystring, e.g. the string you POST would be:
>
> q=fieldname%3Afieldvalue1+OR+fieldname%3Afieldvalue2+OR+fieldname%3Afieldva lue3
>
> Whenever you see some weird error on the client, always check the Solr log
> for the real error reason.
>
> --
> Mauricio
>
> > <solrnet%2Bunsu...@googlegroups.com<solrnet%252Bunsubscribe@googlegroup s.com>

Frederico

unread,
Jul 29, 2010, 3:03:24 PM7/29/10
to SolrNet
Hi Mauricio,
sorry for the late reply...

I didn't manage to solve this issue the way you explained because i
think it wasn't the best approach for my needs...
I reformulate my application to use smaller search strings and it's
been working that way. I'm sorry but my timeplan doesn't permit losing
too much time on these questions so i must choose the quicker way (and
i think i don't have the necessary solr/c# knowledge to perform such
tasks).

In any case, if i make some modifications to solrnet i'll be happy to
share those with you.

Best Regards,
Frederico


On Jul 26, 2:48 pm, Mauricio Scheffer <mauricioschef...@gmail.com>
Reply all
Reply to author
Forward
0 new messages