You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Rohit <ro...@in-rev.com> on 2011/10/14 15:29:45 UTC

SolrJ + Post

I want to user POST instead of GET while using solrj, but I am unable to
find a clear example for it. If anyone has implemented the same it would be
nice to get some insight.

 

Regards,

Rohit

Mobile: +91-9901768202

About Me:  <http://about.me/rohitg> http://about.me/rohitg

 


Re: SolrJ + Post

Posted by Yury Kats <yu...@yahoo.com>.
On 10/14/2011 12:11 PM, Rohit wrote:
> I want to query, right now I use it in the following way,
> 
> CommonsHttpSolrServer server = new CommonsHttpSolrServer("URL HERE");
> SolrQuery sq = new SolrQuery();
> sq.add("q",query);
> QueryResponse qr = server.query(sq);

QueryResponse qr = server.query(sq, METHOD.POST);

RE: SolrJ + Post

Posted by Rohit <ro...@in-rev.com>.
I want to query, right now I use it in the following way,

CommonsHttpSolrServer server = new CommonsHttpSolrServer("URL HERE");
SolrQuery sq = new SolrQuery();
sq.add("q",query);
QueryResponse qr = server.query(sq);

Regards,
Rohit
-----Original Message-----
From: Yury Kats [mailto:yurykats@yahoo.com] 
Sent: 14 October 2011 13:51
To: solr-user@lucene.apache.org
Subject: Re: SolrJ + Post

On 10/14/2011 9:29 AM, Rohit wrote:
> I want to user POST instead of GET while using solrj, but I am unable to
> find a clear example for it. If anyone has implemented the same it would
be
> nice to get some insight.

To do what? Submit? Query? How do you use SolrJ now?


Re: SolrJ + Post

Posted by Yury Kats <yu...@yahoo.com>.
On 10/14/2011 9:29 AM, Rohit wrote:
> I want to user POST instead of GET while using solrj, but I am unable to
> find a clear example for it. If anyone has implemented the same it would be
> nice to get some insight.

To do what? Submit? Query? How do you use SolrJ now?

RE: SolrJ + Post

Posted by Rohit <ro...@in-rev.com>.
Ya the problem is with the length of the URL, with a lot of filters coming
in the length goes beyond the length allowed. But, I guess extending url
length would be a better approcach.

Regards,
Rohit

-----Original Message-----
From: Sujit Pal [mailto:sujit.pal@comcast.net] 
Sent: 14 October 2011 16:54
To: solr-user@lucene.apache.org
Subject: Re: SolrJ + Post

Not the OP, but I put it in on /one/ of my solr custom handlers that
acts as a proxy to itself (ie the server its part of). It basically
rewrites the incoming query (usually short 50-250 chars at most) to a
set of very long queries and passes them in parallel to the server,
gathers up the results and returns a combo response. 

The logging is not an issue for me since the handler logs the expanded
query before sending it off, but the caching is. Thank you for pointing
it out.

I was doing it because I was running afoul of the limit on the URL size
(and the max boolean clauses as well, but I reset the max for that). But
I just realized that we can probably reset that limit as well as this
page shows:
http://serverfault.com/questions/56691/whats-the-maximum-url-length-in-tomca
t 

So perhaps if the URL length is the reason for the OP's question,
increasing it may be a better option than using POST?

-sujit

On Fri, 2011-10-14 at 09:30 -0700, Walter Underwood wrote:
> Why do you want to use POST? It is the wrong HTTP request type for search
results.
> 
> GET is for retrieving information from the server, POST is for changing
information on the server.
> 
> POST responses cannot be cached (see HTTP spec).
> 
> POST requests do not include the arguments in the log, which makes your
HTTP logs nearly useless for diagnosing problems.
> 
> wunder
> Walter Underwood
> 
> On Oct 14, 2011, at 9:20 AM, Sujit Pal wrote:
> 
> > If you use the CommonsHttpSolrServer from your client (not sure about
> > the other types, this is the one I use), you can pass the method as an
> > argument to its query() method, something like this:
> > 
> > QueryResponse rsp = server.query(params, METHOD.POST);
> > 
> > HTH
> > Sujit
> > 
> > On Fri, 2011-10-14 at 13:29 +0000, Rohit wrote:
> >> I want to user POST instead of GET while using solrj, but I am unable
to
> >> find a clear example for it. If anyone has implemented the same it
would be
> >> nice to get some insight.
> >> 
> >> 
> >> 
> >> Regards,
> >> 
> >> Rohit
> >> 
> >> Mobile: +91-9901768202
> >> 
> >> About Me:  <http://about.me/rohitg> http://about.me/rohitg
> >> 
> 
> 
> 
> 



Re: SolrJ + Post

Posted by Sujit Pal <su...@comcast.net>.
Not the OP, but I put it in on /one/ of my solr custom handlers that
acts as a proxy to itself (ie the server its part of). It basically
rewrites the incoming query (usually short 50-250 chars at most) to a
set of very long queries and passes them in parallel to the server,
gathers up the results and returns a combo response. 

The logging is not an issue for me since the handler logs the expanded
query before sending it off, but the caching is. Thank you for pointing
it out.

I was doing it because I was running afoul of the limit on the URL size
(and the max boolean clauses as well, but I reset the max for that). But
I just realized that we can probably reset that limit as well as this
page shows:
http://serverfault.com/questions/56691/whats-the-maximum-url-length-in-tomcat 

So perhaps if the URL length is the reason for the OP's question,
increasing it may be a better option than using POST?

-sujit

On Fri, 2011-10-14 at 09:30 -0700, Walter Underwood wrote:
> Why do you want to use POST? It is the wrong HTTP request type for search results.
> 
> GET is for retrieving information from the server, POST is for changing information on the server.
> 
> POST responses cannot be cached (see HTTP spec).
> 
> POST requests do not include the arguments in the log, which makes your HTTP logs nearly useless for diagnosing problems.
> 
> wunder
> Walter Underwood
> 
> On Oct 14, 2011, at 9:20 AM, Sujit Pal wrote:
> 
> > If you use the CommonsHttpSolrServer from your client (not sure about
> > the other types, this is the one I use), you can pass the method as an
> > argument to its query() method, something like this:
> > 
> > QueryResponse rsp = server.query(params, METHOD.POST);
> > 
> > HTH
> > Sujit
> > 
> > On Fri, 2011-10-14 at 13:29 +0000, Rohit wrote:
> >> I want to user POST instead of GET while using solrj, but I am unable to
> >> find a clear example for it. If anyone has implemented the same it would be
> >> nice to get some insight.
> >> 
> >> 
> >> 
> >> Regards,
> >> 
> >> Rohit
> >> 
> >> Mobile: +91-9901768202
> >> 
> >> About Me:  <http://about.me/rohitg> http://about.me/rohitg
> >> 
> 
> 
> 
> 


Re: SolrJ + Post

Posted by Walter Underwood <wu...@wunderwood.org>.
Why do you want to use POST? It is the wrong HTTP request type for search results.

GET is for retrieving information from the server, POST is for changing information on the server.

POST responses cannot be cached (see HTTP spec).

POST requests do not include the arguments in the log, which makes your HTTP logs nearly useless for diagnosing problems.

wunder
Walter Underwood

On Oct 14, 2011, at 9:20 AM, Sujit Pal wrote:

> If you use the CommonsHttpSolrServer from your client (not sure about
> the other types, this is the one I use), you can pass the method as an
> argument to its query() method, something like this:
> 
> QueryResponse rsp = server.query(params, METHOD.POST);
> 
> HTH
> Sujit
> 
> On Fri, 2011-10-14 at 13:29 +0000, Rohit wrote:
>> I want to user POST instead of GET while using solrj, but I am unable to
>> find a clear example for it. If anyone has implemented the same it would be
>> nice to get some insight.
>> 
>> 
>> 
>> Regards,
>> 
>> Rohit
>> 
>> Mobile: +91-9901768202
>> 
>> About Me:  <http://about.me/rohitg> http://about.me/rohitg
>> 





Re: SolrJ + Post

Posted by Sujit Pal <su...@comcast.net>.
If you use the CommonsHttpSolrServer from your client (not sure about
the other types, this is the one I use), you can pass the method as an
argument to its query() method, something like this:

QueryResponse rsp = server.query(params, METHOD.POST);

HTH
Sujit

On Fri, 2011-10-14 at 13:29 +0000, Rohit wrote:
> I want to user POST instead of GET while using solrj, but I am unable to
> find a clear example for it. If anyone has implemented the same it would be
> nice to get some insight.
> 
>  
> 
> Regards,
> 
> Rohit
> 
> Mobile: +91-9901768202
> 
> About Me:  <http://about.me/rohitg> http://about.me/rohitg
> 
>  
>