Select Git revision
PrepareQuery.pm 6.18 KiB
package SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery;
use v5.36;
use namespace::autoclean;
sub prepare_aip_query ($opt) {
my $query;
my @must;
my @must_not;
my @should;
if (exists $opt->{startrecord}) {
$query->{from} = $opt->{startrecord} - 1; # start from index 0 -> first record
}
if (exists $opt->{maxrecords}) {
$query->{size} = $opt->{maxrecords};
}
if (exists $opt->{source}) {
#push @queries, "IE.sourceMD.content=\"$opt->{source}\"";
}
if (exists $opt->{aip}) {
push @must, {
"match_phrase" => {
"uuid" => "$opt->{aip}"
}
};
}
if (exists $opt->{lzaid}) {
push @must, {
"match_phrase" => {
"transferMetadata.bim:bag-info_dict.bim:SLUBArchiv-lzaId" => "$opt->{lzaid}"
}
};
}
if (exists $opt->{only_migrated}) {
push @must, {
"exists" => {
field => "transferMetadata.bim:bag-info_dict.bim:SLUBArchiv-migrated-AIP"
}
}
}
if (exists $opt->{only_updated}) {
push @must, {
"exists" => {
field => "transferMetadata.bim:bag-info_dict.bim:SLUBArchiv-previous-AIP"
}
}
}
if (exists $opt->{only_new}) {
push @must_not, {
"exists" => {
field => "transferMetadata.bim:bag-info_dict.bim:SLUBArchiv-previous-AIP"
}
}
}
if (exists $opt->{only_ldp_saxon}) {
push @must, {
"match_phrase" => {
"transferMetadata.bim:bag-info_dict.bim:LDP-funder.keyword" => 'LDP: Sachsen'
}
}
}
if (exists $opt->{only_ldp}) {
push @must, {
"exists" => {
field => "transferMetadata.bim:bag-info_dict.bim:LDP-funder"
}
}
}
if (exists $opt->{no_ldp}) {
push @must_not, {
"exists" => {