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 SGE0 <st...@hotmail.com> on 2009/10/23 10:41:19 UTC

SolrJ and Json

Hi ,

I have following problem: 
Using CommonsHttpSolrServer (javabin format) I do a query with wt=json and
get following response (by using  qresponse = solr.query(params); and then
qresponse.toString();

{responseHeader={status=0,QTime=16,params={indent=on,start=0,q=mmm,qt=dismax,wt=[javabin,
javabin],hl=on,rows=10,version=[1,
1]}},response={numFound=0,start=0,docs=[]},highlighting={}}

Now this does not seems to be JSON format (or is it ) ?

Should the equal sign not be a ':' and the values surrounded with double
quotes ?

The problem is that I want to pass the qresponse to a Javascript variable so
the client javascript code can then inspect the JSON response and do
whatever is needed.

What I did was:

 var str = "<%=qresponse.toString()%>"; 

but I can't seem to correctly read the str variable as a JSON object and
parse it (on the client side).

Any ideas or code snippets to show the correct way ?

Regards,

St.





-- 
View this message in context: http://www.nabble.com/SolrJ-and-Json-tp26022705p26022705.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SolrJ and Json

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>.
Why don't you directly hit Solr with wt=json? That will give you the
output as JSON

On Fri, Oct 23, 2009 at 5:53 PM, SGE0 <st...@hotmail.com> wrote:
>
> Hi,
>
> thx for the fast response.
>
> So, is there a way to convert the response (javabin) to JSON ?
>
> Regards,
>
> S.
>
>
>
>
>
>
> Noble Paul നോബിള്‍  नोब्ळ्-2 wrote:
>>
>> CommonsHttpSolrServer will overwrite the wt param depending on the
>> responseParser set.There are  only two response parsers. javabin and
>> xml.
>>
>> The qresponse.toString() actually is a String reperesentation of a
>> namedList object . it has nothing to do with JSON
>>
>> On Fri, Oct 23, 2009 at 2:11 PM, SGE0 <st...@hotmail.com> wrote:
>>>
>>> Hi ,
>>>
>>> I have following problem:
>>> Using CommonsHttpSolrServer (javabin format) I do a query with wt=json
>>> and
>>> get following response (by using  qresponse = solr.query(params); and
>>> then
>>> qresponse.toString();
>>>
>>> {responseHeader={status=0,QTime=16,params={indent=on,start=0,q=mmm,qt=dismax,wt=[javabin,
>>> javabin],hl=on,rows=10,version=[1,
>>> 1]}},response={numFound=0,start=0,docs=[]},highlighting={}}
>>>
>>> Now this does not seems to be JSON format (or is it ) ?
>>>
>>> Should the equal sign not be a ':' and the values surrounded with double
>>> quotes ?
>>>
>>> The problem is that I want to pass the qresponse to a Javascript variable
>>> so
>>> the client javascript code can then inspect the JSON response and do
>>> whatever is needed.
>>>
>>> What I did was:
>>>
>>>  var str = "<%=qresponse.toString()%>";
>>>
>>> but I can't seem to correctly read the str variable as a JSON object and
>>> parse it (on the client side).
>>>
>>> Any ideas or code snippets to show the correct way ?
>>>
>>> Regards,
>>>
>>> St.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/SolrJ-and-Json-tp26022705p26022705.html
>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> -----------------------------------------------------
>> Noble Paul | Principal Engineer| AOL | http://aol.com
>>
>>
>
> --
> View this message in context: http://www.nabble.com/SolrJ-and-Json-tp26022705p26025339.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com

Re: SolrJ and Json

Posted by SGE0 <st...@hotmail.com>.
Hi, 

thx for the fast response.

So, is there a way to convert the response (javabin) to JSON ?

Regards,

S.






Noble Paul നോബിള്‍  नोब्ळ्-2 wrote:
> 
> CommonsHttpSolrServer will overwrite the wt param depending on the
> responseParser set.There are  only two response parsers. javabin and
> xml.
> 
> The qresponse.toString() actually is a String reperesentation of a
> namedList object . it has nothing to do with JSON
> 
> On Fri, Oct 23, 2009 at 2:11 PM, SGE0 <st...@hotmail.com> wrote:
>>
>> Hi ,
>>
>> I have following problem:
>> Using CommonsHttpSolrServer (javabin format) I do a query with wt=json
>> and
>> get following response (by using  qresponse = solr.query(params); and
>> then
>> qresponse.toString();
>>
>> {responseHeader={status=0,QTime=16,params={indent=on,start=0,q=mmm,qt=dismax,wt=[javabin,
>> javabin],hl=on,rows=10,version=[1,
>> 1]}},response={numFound=0,start=0,docs=[]},highlighting={}}
>>
>> Now this does not seems to be JSON format (or is it ) ?
>>
>> Should the equal sign not be a ':' and the values surrounded with double
>> quotes ?
>>
>> The problem is that I want to pass the qresponse to a Javascript variable
>> so
>> the client javascript code can then inspect the JSON response and do
>> whatever is needed.
>>
>> What I did was:
>>
>>  var str = "<%=qresponse.toString()%>";
>>
>> but I can't seem to correctly read the str variable as a JSON object and
>> parse it (on the client side).
>>
>> Any ideas or code snippets to show the correct way ?
>>
>> Regards,
>>
>> St.
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/SolrJ-and-Json-tp26022705p26022705.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> -----------------------------------------------------
> Noble Paul | Principal Engineer| AOL | http://aol.com
> 
> 

-- 
View this message in context: http://www.nabble.com/SolrJ-and-Json-tp26022705p26025339.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: SolrJ and Json

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>.
CommonsHttpSolrServer will overwrite the wt param depending on the
responseParser set.There are  only two response parsers. javabin and
xml.

The qresponse.toString() actually is a String reperesentation of a
namedList object . it has nothing to do with JSON

On Fri, Oct 23, 2009 at 2:11 PM, SGE0 <st...@hotmail.com> wrote:
>
> Hi ,
>
> I have following problem:
> Using CommonsHttpSolrServer (javabin format) I do a query with wt=json and
> get following response (by using  qresponse = solr.query(params); and then
> qresponse.toString();
>
> {responseHeader={status=0,QTime=16,params={indent=on,start=0,q=mmm,qt=dismax,wt=[javabin,
> javabin],hl=on,rows=10,version=[1,
> 1]}},response={numFound=0,start=0,docs=[]},highlighting={}}
>
> Now this does not seems to be JSON format (or is it ) ?
>
> Should the equal sign not be a ':' and the values surrounded with double
> quotes ?
>
> The problem is that I want to pass the qresponse to a Javascript variable so
> the client javascript code can then inspect the JSON response and do
> whatever is needed.
>
> What I did was:
>
>  var str = "<%=qresponse.toString()%>";
>
> but I can't seem to correctly read the str variable as a JSON object and
> parse it (on the client side).
>
> Any ideas or code snippets to show the correct way ?
>
> Regards,
>
> St.
>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/SolrJ-and-Json-tp26022705p26022705.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com