Re: JSON formatted response from SOLR question....

2010-05-11 Thread Tod

Jon,

Yes!!!

rsp.facet_counts.facet_fields.['var'].length to
rsp.facet_counts.facet_fields[var].length and voila.

Tripped up on a syntax error, how special.  Just needed another set of 
eyes - thanks.  VelocityResponse duly noted, it will come in handy later.



- Tod

On 5/10/2010 4:55 PM, Jon Baer wrote:

IIRC, I think what we ended up doing in a project was to use the 
VelocityResponseWriter to write the JSON and set the echoParams to read the 
handler setup (and looping through the variables).

In the template you can grab it w/ something like 
$request.params.get("facet_fields") ... I don't remember the exact hack here 
but basically you should also be able to do something like:

rsp.facet_counts.facet_fields['var'].length

In the end w/ some of the nice stuff from the Velocity tools .jar it was easier 
to work w/ the layout needed for plugins.

- Jon

On May 10, 2010, at 10:18 AM, Tod wrote:


I apologize, this is such a JSON/javascript question but I'm stuck and am not 
finding any resources that address this specifically.

I'm doing a faceted search and getting back in my facet_counts.faceted_fields 
response an array of countries.  I'm gathering the count of the array elements 
returned using this notation:

rsp.facet_counts.facet_fields.country.length

... where rsp is the eval'ed JSON response from SOLR.  From there I just loop 
through listing the individual country with its associated count.

The problem I am having is trying to automate this to loop through any one of a 
number of facets contained in my JSON response, not just country.  So instead 
of the above I would have something like:

rsp.facet_counts.facet_fields.VARIABLE.length

... where VARIABLE would be the name of one of the facets passed into a 
javascript function to perform the loop.  None of the javascript examples I can 
find seems to address this.  Has anyone run into this? Is there a better list 
to ask this question?


Thanks in advance.







Re: JSON formatted response from SOLR question....

2010-05-10 Thread Jon Baer
IIRC, I think what we ended up doing in a project was to use the 
VelocityResponseWriter to write the JSON and set the echoParams to read the 
handler setup (and looping through the variables).

In the template you can grab it w/ something like 
$request.params.get("facet_fields") ... I don't remember the exact hack here 
but basically you should also be able to do something like:

rsp.facet_counts.facet_fields['var'].length

In the end w/ some of the nice stuff from the Velocity tools .jar it was easier 
to work w/ the layout needed for plugins.

- Jon

On May 10, 2010, at 10:18 AM, Tod wrote:

> I apologize, this is such a JSON/javascript question but I'm stuck and am not 
> finding any resources that address this specifically.
> 
> I'm doing a faceted search and getting back in my facet_counts.faceted_fields 
> response an array of countries.  I'm gathering the count of the array 
> elements returned using this notation:
> 
> rsp.facet_counts.facet_fields.country.length
> 
> ... where rsp is the eval'ed JSON response from SOLR.  From there I just loop 
> through listing the individual country with its associated count.
> 
> The problem I am having is trying to automate this to loop through any one of 
> a number of facets contained in my JSON response, not just country.  So 
> instead of the above I would have something like:
> 
> rsp.facet_counts.facet_fields.VARIABLE.length
> 
> ... where VARIABLE would be the name of one of the facets passed into a 
> javascript function to perform the loop.  None of the javascript examples I 
> can find seems to address this.  Has anyone run into this? Is there a better 
> list to ask this question?
> 
> 
> Thanks in advance.



RE: JSON formatted response from SOLR question....

2010-05-10 Thread caman

Take a look at AjaxSolr source code:

 

http://github.com/evolvingweb/ajax-solr

 

This should give you exactly what you need.

 

thanks

 

 

 

 

From: Tod [via Lucene]
[mailto:ml-node+789105-593266572-124...@n3.nabble.com] 
Sent: Monday, May 10, 2010 7:22 AM
To: caman
Subject: JSON formatted response from SOLR question

 

I apologize, this is such a JSON/javascript question but I'm stuck and 
am not finding any resources that address this specifically. 

I'm doing a faceted search and getting back in my 
facet_counts.faceted_fields response an array of countries.  I'm 
gathering the count of the array elements returned using this notation: 

rsp.facet_counts.facet_fields.country.length 

... where rsp is the eval'ed JSON response from SOLR.  From there I just 
loop through listing the individual country with its associated count. 

The problem I am having is trying to automate this to loop through any 
one of a number of facets contained in my JSON response, not just 
country.  So instead of the above I would have something like: 

rsp.facet_counts.facet_fields.VARIABLE.length 

... where VARIABLE would be the name of one of the facets passed into a 
javascript function to perform the loop.  None of the javascript 
examples I can find seems to address this.  Has anyone run into this? 
Is there a better list to ask this question? 


Thanks in advance. 



  _  

View message @
http://lucene.472066.n3.nabble.com/JSON-formatted-response-from-SOLR-questio
n-tp789105p789105.html 
To start a new topic under Solr - User, email
ml-node+472068-464289649-124...@n3.nabble.com 
To unsubscribe from Solr - User, click
< (link removed) 
GZvcnRoZW90aGVyc3R1ZmZAZ21haWwuY29tfDQ3MjA2OHwtOTM0OTI1NzEx>  here. 

 


-- 
View this message in context: 
http://lucene.472066.n3.nabble.com/JSON-formatted-response-from-SOLR-question-tp789105p789183.html
Sent from the Solr - User mailing list archive at Nabble.com.