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 Jason Rutherglen <ja...@gmail.com> on 2010/02/08 18:32:03 UTC
Call URL, simply parse the results using SolrJ
Sorry for the poorly worded title... For SOLR-1761 I want to pass in a
URL and parse the query response... However it's non-obvious to me how
to do this using the SolrJ API, hence asking the experts here. :)
Re: Call URL, simply parse the results using SolrJ
Posted by Noble Paul നോബിള് नोब्ळ् <no...@corp.aol.com>.
you can also try
URL urlo = new URL(url);// ensure that the url has wt=javabin in that
NamedList<Object> namedList = new
JavaBinCodec().unmarshal(urlo.openConnection().getInputStream());
QueryResponse response = new QueryResponse(namedList, null);
On Mon, Feb 8, 2010 at 11:49 PM, Jason Rutherglen
<ja...@gmail.com> wrote:
> Here's what I did to resolve this:
>
> XMLResponseParser parser = new XMLResponseParser();
> URL urlo = new URL(url);
> InputStreamReader isr = new
> InputStreamReader(urlo.openConnection().getInputStream());
> NamedList<Object> namedList = parser.processResponse(isr);
> QueryResponse response = new QueryResponse(namedList, null);
>
> On Mon, Feb 8, 2010 at 10:03 AM, Jason Rutherglen
> <ja...@gmail.com> wrote:
>> So here's what happens if I pass in a URL with parameters, SolrJ chokes:
>>
>> Exception in thread "main" java.lang.RuntimeException: Invalid base
>> url for solrj. The base URL must not contain parameters:
>> http://locahost:8080/solr/main/select?q=video&qt=dismax
>> at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:205)
>> at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:180)
>> at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:152)
>> at org.apache.solr.util.QueryTime.main(QueryTime.java:20)
>>
>>
>> On Mon, Feb 8, 2010 at 9:32 AM, Jason Rutherglen
>> <ja...@gmail.com> wrote:
>>> Sorry for the poorly worded title... For SOLR-1761 I want to pass in a
>>> URL and parse the query response... However it's non-obvious to me how
>>> to do this using the SolrJ API, hence asking the experts here. :)
>>>
>>
>
--
-----------------------------------------------------
Noble Paul | Systems Architect| AOL | http://aol.com
Re: Call URL, simply parse the results using SolrJ
Posted by Jason Rutherglen <ja...@gmail.com>.
Here's what I did to resolve this:
XMLResponseParser parser = new XMLResponseParser();
URL urlo = new URL(url);
InputStreamReader isr = new
InputStreamReader(urlo.openConnection().getInputStream());
NamedList<Object> namedList = parser.processResponse(isr);
QueryResponse response = new QueryResponse(namedList, null);
On Mon, Feb 8, 2010 at 10:03 AM, Jason Rutherglen
<ja...@gmail.com> wrote:
> So here's what happens if I pass in a URL with parameters, SolrJ chokes:
>
> Exception in thread "main" java.lang.RuntimeException: Invalid base
> url for solrj. The base URL must not contain parameters:
> http://locahost:8080/solr/main/select?q=video&qt=dismax
> at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:205)
> at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:180)
> at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:152)
> at org.apache.solr.util.QueryTime.main(QueryTime.java:20)
>
>
> On Mon, Feb 8, 2010 at 9:32 AM, Jason Rutherglen
> <ja...@gmail.com> wrote:
>> Sorry for the poorly worded title... For SOLR-1761 I want to pass in a
>> URL and parse the query response... However it's non-obvious to me how
>> to do this using the SolrJ API, hence asking the experts here. :)
>>
>
Re: Call URL, simply parse the results using SolrJ
Posted by Jason Rutherglen <ja...@gmail.com>.
Ahmet, Thanks, though that isn't quite what I was going for, and it's
resolved besides...
On Mon, Feb 8, 2010 at 10:24 AM, Ahmet Arslan <io...@yahoo.com> wrote:
>> So here's what happens if I pass in a
>> URL with parameters, SolrJ chokes:
>>
>> Exception in thread "main" java.lang.RuntimeException:
>> Invalid base
>> url for solrj. The base URL must not contain
>> parameters:
>> http://locahost:8080/solr/main/select?q=video&qt=dismax
>
> You can't pass url with parameters to CommonsHttpSolrServer constructor.
> You need to create a SolrQuery representing your parameters and vaules.
> Your url can be translated into something like:
>
> server = new CommonsHttpSolrServer("http://locahost:8080/solr/main/");
>
> final SolrQuery query = new SolrQuery();
> query.setQueryType("dismax");
> query.setQuery("video");
>
> final QueryResponse rsp = server.query(query);
>
>
>
>
>
Re: Call URL, simply parse the results using SolrJ
Posted by Ahmet Arslan <io...@yahoo.com>.
> So here's what happens if I pass in a
> URL with parameters, SolrJ chokes:
>
> Exception in thread "main" java.lang.RuntimeException:
> Invalid base
> url for solrj. The base URL must not contain
> parameters:
> http://locahost:8080/solr/main/select?q=video&qt=dismax
You can't pass url with parameters to CommonsHttpSolrServer constructor.
You need to create a SolrQuery representing your parameters and vaules.
Your url can be translated into something like:
server = new CommonsHttpSolrServer("http://locahost:8080/solr/main/");
final SolrQuery query = new SolrQuery();
query.setQueryType("dismax");
query.setQuery("video");
final QueryResponse rsp = server.query(query);
Re: Call URL, simply parse the results using SolrJ
Posted by Jason Rutherglen <ja...@gmail.com>.
So here's what happens if I pass in a URL with parameters, SolrJ chokes:
Exception in thread "main" java.lang.RuntimeException: Invalid base
url for solrj. The base URL must not contain parameters:
http://locahost:8080/solr/main/select?q=video&qt=dismax
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:205)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:180)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<init>(CommonsHttpSolrServer.java:152)
at org.apache.solr.util.QueryTime.main(QueryTime.java:20)
On Mon, Feb 8, 2010 at 9:32 AM, Jason Rutherglen
<ja...@gmail.com> wrote:
> Sorry for the poorly worded title... For SOLR-1761 I want to pass in a
> URL and parse the query response... However it's non-obvious to me how
> to do this using the SolrJ API, hence asking the experts here. :)
>