Skip to content
Snippets Groups Projects
Commit 516a127a authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- added '--with-score'

- fixed output  logic
parent ead90c6b
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,7 @@ sub opt_spec {
[ "with-filecount" => "also returns AIPs file count" ],
[ "with-export2archive-date" => "also returns AIP export to archive date" ],
[ "with-creationdate" => "also returns AIP creation date" ],
[ "with-score" => "also returns score of Elastic Search match (higher => better)"],
[],
[ 'help|h', "print usage message and exit", { shortcircuit => 1 } ],
[ 'version|v', "print version information", { shortcircuit => 1 } ],
......@@ -108,6 +109,7 @@ sub line_result_mapper {
if (defined $opt->{with_filecount}) { $line{filecount} = $partial_result->{_source}->{file_count} };
if (defined $opt->{with_export2archive_date}) { $line{export2archive_date}=$partial_result->{_source}->{transferMetadata}->[0]->{'SLUBArchiv-exportToArchiveDate'} };
if (defined $opt->{with_creation_date}) { $line{creation_date} = $partial_result->{_source}->{created} };
if (defined $opt->{with_score}) { $line{score} = $partial_result->{_score}}
\%line;
}
......@@ -136,9 +138,8 @@ sub execute {
my @headers = sort keys %{$result[0]};
my $aip_only = List::Util::none {$_ =~ m/^with/} keys %{ $opt };
p($opt);
if ($opt->{output_format} eq 'output_as_raw') {
say np($response);
} elsif ($aip_only or ($opt->{output_format} eq 'output_as_csv') ) {
if (!exists $opt->{output_format}) { $opt->{output_format} = 'output_as_rsv' ;}
if ($aip_only or ($opt->{output_format} eq 'output_as_csv') ) {
say join(",", @headers);
say join("\n", map {
my $line = $_;
......@@ -156,6 +157,8 @@ p($opt);
print join(CHR_ROW_TERMINATOR, map { join(CHR_VALUE_TERMINATOR,values %{ $_ }); } @result);
print CHR_ROW_TERMINATOR;
binmode(STDOUT, ':encoding(UTF-8)');
} elsif ($opt->{output_format} eq 'output_as_raw') {
say np($response);
}
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment