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

- added support for --start_record

- added support for --max_records
- added aip search
parent 62d0d054
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ our @EXPORT_OK = qw();
sub _instantiate($protocol, $host, $port) {
return Search::Elasticsearch->new(
nodes => "$protocol://$host:$port",
#trace_to => 'Stderr',
trace_to => 'Stderr',
#cnx_pool => 'Sniff',
cxn_pool => 'Static::NoPing',
client => '6_0::Direct'
......@@ -44,6 +44,8 @@ sub query_elasticsearch($protocol, $host, $port, $index_name, $query_hash, $opti
}
if ((defined $options) and ($options->{no_source} == 1)) {
$local_query_hash->{_source}="false"; # avoids transfering complete source tree in results
} else {
#$local_query_hash->{_source}->{excludes}=""
}
my $e = _instantiate($protocol, $host, $port);
......@@ -60,24 +62,36 @@ sub query_elasticsearch_count($protocol, $host, $port, $index_name, $query_hash)
}
sub prepare_query ($opt) {
my $query;
my @must;
my @should;
if (exists $opt->{start_record}) {
$query->{from} = $opt->{start_record} - 1; # start from index 0 -> first record
}
if (exists $opt->{max_records}) {
$query->{size} = $opt->{max_records};
}
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" => {
"transferMetadata.SLUBArchiv-lzaId" =>
"$opt->{lzaid}"
"match_phrase" => {
"transferMetadata.SLUBArchiv-lzaId" => "$opt->{lzaid}"
}
};
}
if (exists $opt->{descriptive}) {
push @should, {
match => {
"transferMetadata.dc" => "$opt->{descriptive}",
"match" => {
"transferMetadata.*" => "$opt->{descriptive}",
}
}
}
......@@ -112,13 +126,14 @@ sub prepare_query ($opt) {
#push @queries, "FILE.fileVirusCheck.status==\"\"";
}
#my $query = join(" and ", @queries);
my $query;
# 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 @should > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment