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 (Archbishop) 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.


    🦛