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 Cord Thomas <co...@gmail.com> on 2013/05/13 20:05:31 UTC

Faceting json response - odd format

Hello,

Relatively new to SOLR, I am quite happy with the API. 

I am a bit challenged by the faceting response in JSON though. 

This is what i am getting which mirrors what is in the documentation:

"facet_counts":{"facet_queries":{},
    "facet_fields":{"metadata_meta_last_author":["Nick",330,"standarduser",153,"Mohan",52,"wwd",49,"gerald",45,"Riggins",36,"fallon",31,"blister",28," ",26,"morfitelli",24,"Administrator",22,"morrow",22,"richard",22,"egilhoi",18,"USer Group",16],
  

This is not trivial to parse - I've read the docs but can't seem to figure out who one might get a more structured response to this.

Assuming I am not missing anything,  I guess i have to write a custom parser to build a separate data structure that can be more easily presented in a UI.  

Thank you

Cord

Re: Faceting json response - odd format

Posted by Chris Hostetter <ho...@fucit.org>.
: What i would prefer to see as we do with all other parameters is a 
: normal key/value pairing.  this might look like:

a true key value pairing via a "map" type structure is what you get with 
json.nl=map -- but in most client langauges that would lose whatever 
sorting you might have specified with facet.sort.

: {"metadata_meta_last_author":[{"value": "Nick", "count": 330},{"value": 
: "standard user","count": 153},{"value": "Mohan","count": 
: 52},{"value":"wwd","count": 49}…

that structure is essentially what you get with json.nl=arrarr -- ie: the
values are still in the specified facet.sort order; but instead of an
array of maps, it's an array of array "pairs".

This is the most close equivilent to how the facet counts are internally 
modeled -- you should be able to inject those keys you choose ("value" and 
"count") in your client layer fairely easily.


-Hoss

Re: Faceting json response - odd format

Posted by Cord Thomas <co...@gmail.com>.
thank you Hoss,

What i would prefer to see as we do with all other parameters is a normal key/value pairing.  this might look like:

{"metadata_meta_last_author":[{"value": "Nick", "count": 330},{"value": "standard user","count": 153},{"value": "Mohan","count": 52},{"value":"wwd","count": 49}…

Cord

On May 13, 2013, at 12:34 PM, Chris Hostetter <ho...@fucit.org> wrote:

> 
> : This is what i am getting which mirrors what is in the documentation:
> : 
> : "facet_counts":{"facet_queries":{},
> :     "facet_fields":{"metadata_meta_last_author":["Nick",330,"standarduser",153,"Mohan",52,"wwd",49,"gerald",45,"Riggins",36,"fallon",31,"blister",28," ",26,"morfitelli",24,"Administrator",22,"morrow",22,"richard",22,"egilhoi",18,"USer Group",16],
> :   
> : 
> : This is not trivial to parse - I've read the docs but can't seem to 
> : figure out who one might get a more structured response to this.
> 
> You didn't provide any specifics about what you felt was problematic, but 
> i'm guessing what you want to do is pick the value you think is best for 
> the "json.nl" param...
> 
> http://wiki.apache.org/solr/SolJSON#JSON_specific_parameters
> 
> 
> -Hoss


Re: Faceting json response - odd format

Posted by Chris Hostetter <ho...@fucit.org>.
: This is what i am getting which mirrors what is in the documentation:
: 
: "facet_counts":{"facet_queries":{},
:     "facet_fields":{"metadata_meta_last_author":["Nick",330,"standarduser",153,"Mohan",52,"wwd",49,"gerald",45,"Riggins",36,"fallon",31,"blister",28," ",26,"morfitelli",24,"Administrator",22,"morrow",22,"richard",22,"egilhoi",18,"USer Group",16],
:   
: 
: This is not trivial to parse - I've read the docs but can't seem to 
: figure out who one might get a more structured response to this.

You didn't provide any specifics about what you felt was problematic, but 
i'm guessing what you want to do is pick the value you think is best for 
the "json.nl" param...

http://wiki.apache.org/solr/SolJSON#JSON_specific_parameters


-Hoss