Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: How to retrieve WebService::Solr facet value properly?

by swiftlet (Acolyte)
on Aug 07, 2020 at 07:06 UTC ( [id://11120452]=note: print w/replies, xml ) Need Help??


in reply to Re: How to retrieve WebService::Solr facet value properly?
in thread How to retrieve WebService::Solr facet value properly?

Thanks for your information, I have just tried it. Seem like that's the official way to get facet count, but I don't like they put facet field and facet count in one array, maybe my "Dumper +Regex" is safer.

my $facet_counts = $response->facet_counts; my $autId = $facet_counts->{facet_fields}{author_id}; print Dumper(\$autId), "<br>"; for(my $i=0; $i < int(@{$autId}); $i++){ print @{$autId}[$i], ": ", @{$autId}[++$i], "<br>\n"; };
Output:

$VAR1 = \[ '9291', 131, '3389', 88, '622', 85, '123715', 81, '5091', 6 +3 ]; 9291: 131 3389: 88 622: 85 123715: 81 5091: 63

Replies are listed 'Best First'.
Re^3: How to retrieve WebService::Solr facet value properly?
by hippo (Bishop) on Aug 07, 2020 at 07:35 UTC
    I don't like they put facet field and facet count in one array,

    So, just hashify it yourself (although you'll lose the sorting, of course):

    my $autId = $facet_counts->{facet_fields}{author_id}; my %easy_hash = @$autId;
    maybe my "Dumper +Regex" is safer.

    Almost certainly not. Take the robust approach and then post-process the data as desired.


    🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11120452]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-19 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found