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

- add new option to search only new, only migrated or only updated aips

parent 2801405f
Branches
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ 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
......@@ -29,6 +30,27 @@ sub prepare_aip_query ($opt) {
}
};
}
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->{descriptive}) {
#https://opster.com/guides/elasticsearch/search-apis/elasticsearch-match-multi-match-and-match-phrase-queries/#Multi-match-query
push @should, {
......@@ -51,6 +73,13 @@ sub prepare_aip_query ($opt) {
if (exists $opt->{modificationdate}) {
#push @queries, "FILE.objectCharacteristics.modificationDate==$opt->{modificationdate}";
}
if (exists $opt->{workflow}) { # LZA Workflow search
push @must, {
"match_phrase" => {
"transferMetadata.ObjectType_dict.Metadata_dict.WorkflowName" => $opt->{workflow}
}
};
}
if (exists $opt->{'with_format'}) {
#push @queries, "FILE.generalFileCharacteristics.formatLibraryId==$opt->{'with_format'}";
}
......@@ -74,25 +103,21 @@ sub prepare_aip_query ($opt) {
}
#my $query = join(" and ", @queries);
# my $must_s;
if (scalar @must > 0) {
# $must_s= {
# must => [ @must ]
# };
$query->{query}->{bool}->{must} = \@must ;
#$query->{query}->{bool}->{must} = \@must ;
}
my $should_s;
if (scalar @must_not > 0) {
$query->{query}->{bool}->{must_not} = \@must_not ;
}
if (scalar @should > 0) {
# $should_s={
# should => [ @should ]
# };
$query->{query}->{bool}->{should} = \@should ;
}
if (exists $opt->{debug}) {
use Data::Printer;
say STDERR "\@must=",np(@must);
say STDERR "\@must_not=", np(@must_not);
say STDERR "\@should=",np(@should);
}
return $query;
......
......@@ -48,6 +48,13 @@ sub opt_spec {
["pronom-id|p=s" => "with pronom format id"],
#["without-format=s" => "without pronom format id"],
] } ],
[ 'onlymode' => hidden => {
one_of => [
[ 'only-migrated', 'only if migrated from other AIS' ],
[ 'only-updated', 'only if AIP is an AIP update' ],
[ 'only-new|only-first-ingest', 'only if AIP is first ingest' ],
] } ],
[ 'workflow|w=s' => 'LZA internal workflow name'],
[],
[ 'help|h', 'print usage message and exit', { shortcircuit => 1 } ],
[ 'version|v', 'print version information', { shortcircuit => 1 } ],
......
......@@ -69,6 +69,13 @@ sub opt_spec {
[ 'pronom-id|p=s' => 'with pronom format id' ],
#['without-format=s' => 'without pronom format id'],
] } ],
[ 'onlymode' => hidden => {
one_of => [
[ 'only-migrated', 'only if migrated from other AIS' ],
[ 'only-updated', 'only if AIP is an AIP update' ],
[ 'only-new|only-first-ingest', 'only if AIP is first ingest' ],
] } ],
[ 'workflow|w=s' => 'LZA internal workflow name'],
[],
[ 'with-creationdate' => 'also returns AIP creation date' ],
[ 'with-external-description' => 'also returns AIP external-description'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment