Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tools for technical analysts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
tools for technical analysts
Commits
a311b346
Commit
a311b346
authored
1 year ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- fixed parts of query builder in prepare_query()
parent
3b42eed6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SLUB/LZA/TA/Archivematica/Elasticsearch.pm
+10
-103
10 additions, 103 deletions
lib/SLUB/LZA/TA/Archivematica/Elasticsearch.pm
with
10 additions
and
103 deletions
lib/SLUB/LZA/TA/Archivematica/Elasticsearch.pm
+
10
−
103
View file @
a311b346
...
...
@@ -46,6 +46,7 @@ sub query_elasticsearch($protocol, $host, $port, $index_name, $query_hash, $opti
$local_query_hash
->
{
_source
}
=
"
false
";
# avoids transfering complete source tree in results
}
my
$e
=
_instantiate
(
$protocol
,
$host
,
$port
);
my
$res
=
$e
->
search
(
index
=>
$index_name
,
body
=>
$local_query_hash
,
#hashref
...
...
@@ -61,123 +62,27 @@ sub query_elasticsearch_count($protocol, $host, $port, $index_name, $query_hash)
sub
prepare_query
($opt) {
my
@must
;
my
@should
;
# example query:
# query => {
# bool => {
# must =>
# [
# {
# match => {
# "transferMetadata.SLUBArchiv-externalWorkflow", "testcases",
# },
# },
# ],
# should => [
# {
# match => {
# "transferMetadata.SLUBArchiv-externalId", "test-sip_2020-07-17_13-40-17_96152",
# },
# }
# ]
# },
# }
# Is a SLUB-specific ID in the archive?
# curl -XGET -H 'Content-Type: application/json'
# 'localhost:9200/aips/_search?pretty=true' -d '
# {
# "query": {
# "term": {
# "transferMetadata.SLUBArchiv-lzaId.keyword":
# "SLUB:LZA:testworkflow:testcases:test-sip_2020-07-17_13-40-17_96152"
# }
# }
# }'
#
# What is the "SLUBArchiv-exportToArchiveDate" value of all matches
# curl -XGET -H 'Content-Type: application/json'
# 'localhost:9200/aips/_search?pretty=true' -d '
# {
# "query": {
# "match_all": {}
# },
# "_source": [
# "transferMetadata.SLUBArchiv-lzaId",
# "transferMetadata.SLUBArchiv-exportToArchiveDate"
# ]
# }'
#
# Find all AIPs with a SLUB-specific rights status
# curl -XGET -H 'Content-Type: application/json'
# 'localhost:9200/aips/_search?pretty=true' -d '
# {
# "query": {
# "term": {
# "transferMetadata.slubarchiv:rightsRecord_dict.slubarchiv:copyrightStatus.keyw
# ord": "copyrighted"
# }
# },
# "_source": ["uuid"]
# }'
#
# Reporting for a given date range: AIP count,
# number of archived files, size of archived data, etc.
# curl -XGET -H 'Content-Type: application/json'
# 'localhost:9200/aips/_search?pretty=true' -d '
# {
# "query": {
# "range": {
# "created": {
# "gte": 1638313200,
# "lt": 1640991600
# }
# }
# },
# "aggs": {
# "total_size": {"sum": {"field": "size"}},
# "total_file_count": {"sum": {"field": "file_count"}}
# },
# "size": 0
# }'
# Free Search - Find AIPs based on catalog data
# included by producers
# curl -XGET -H 'Content-Type: application/json'
# 'localhost:9200/aips/_search?pretty=true' -d '
# {
#"query": {
# "query_string": {
# "fields": [
# "transferMetadata.record_dict.datafield_dict.subfield",
# "transferMetadata.mods:mods_dict.mods:titleInfo_dict.mods:title"
# ],
# "query": "Riesaer Tageblatt und Anzeiger"
# }
#},
#"_source": ["uuid"]
#}'
if
(
exists
$opt
->
{
source
})
{
#push @queries, "IE.sourceMD.content=\"$opt->{source}\"";
}
if
(
exists
$opt
->
{
lzaid
})
{
push
@must
,
{
"
term
"
=>
{
"
transferMetadata.SLUBArchiv-lzaId
.keyword
"
=>
"
match
"
=>
{
"
transferMetadata.SLUBArchiv-lzaId
"
=>
"
$opt
->{lzaid}
"
}
};
}
if
(
exists
$opt
->
{
descriptive
})
{
push
@should
=>
{
push
@should
,
{
match
=>
{
"
transferMetadata.dc
"
=>
"
$opt
->{descriptive}
",
}
}
}
if
(
exists
$opt
->
{
creationdate
})
{
push
@should
=>
{
push
@should
,
{
"
created
"
=>
$opt
->
{
creationdate
}
};
}
...
...
@@ -213,14 +118,14 @@ sub prepare_query ($opt) {
# $must_s= {
# must => [ @must ]
# };
$query
->
{
query
}
->
{
bool
}
->
{
must
}
=
[
@must
]
;
$query
->
{
query
}
->
{
bool
}
->
{
must
}
=
\
@must
;
}
my
$should_s
;
if
(
scalar
@should
>
0
)
{
# $should_s={
# should => [ @should ]
# };
$query
->
{
query
}
->
{
bool
}
->
{
should
}
=
[
@should
]
;
$query
->
{
query
}
->
{
bool
}
->
{
should
}
=
\
@should
;
}
if
(
exists
$opt
->
{
debug
})
{
...
...
@@ -228,7 +133,9 @@ sub prepare_query ($opt) {
say
"
opt=
",
np
(
$opt
);
say
"
\@
must=
",
np
(
@must
);
say
"
\@
should=
",
np
(
@should
);
say
"
QUERY=
",
np
(
$query
);
say
"
------------------------
";
say
"
query=
",
np
(
$query
);
say
"
------------------------
";
}
return
$query
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment