Skip to content

ES syntax - make compatible with newer versions #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions bin/check.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
fields => [
qw< name release author distribution version authorized indexed maturity date >
],
query => { match_all => {} },
filter => {
and => [
{ term => { 'module.name' => $pkg } },
{ term => { authorized => 'true' } },
{ term => { maturity => 'released' } },
],
query => {
bool => {
must => [
{ term => { 'module.name' => $pkg } },
{ term => { authorized => 'true' } },
{ term => { maturity => 'released' } },
],
},
},
);
my @files = @{ $results->{hits}{hits} };
Expand All @@ -58,12 +59,13 @@
my $release_results = $es_release->search(
size => 1,
fields => [qw< name status authorized version id date >],
query => { match_all => {} },
filter => {
and => [
{ term => { name => $file->{fields}{release} } },
{ term => { status => 'latest' } },
],
query => {
bool => {
must => [
{ term => { name => $file->{fields}{release} } },
{ term => { status => 'latest' } },
],
},
},
);

Expand All @@ -79,11 +81,12 @@
size => 1,
fields =>
[qw< name status authorized version id date >],
query => { match_all => {} },
filter => {
and => [ {
term => { name => $file->{fields}{release} }
} ]
query => {
bool => {
must => [
{ term => { name => $file->{fields}{release} } },
],
},
},
);

Expand Down
62 changes: 26 additions & 36 deletions bin/latest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ()
# 'file' type records where the module.name matches the
# distribution name and which are released &
# indexed (the 'leading' module)
my $q_body = _body_filtered_query($filter);
my $q_body = _body_query($filter);

my $scroll = $es->scroll(
body => $q_body,
Expand Down Expand Up @@ -219,31 +219,26 @@ ($filter)
return \@module_filters;
}

sub _body_filtered_query ($filter) {
sub _body_query ($filter) {
return +{
query => {
filtered => {
query => { match_all => {} },
filter => {
bool => {
must => [
{
nested => {
path => 'module',
query => { bool => { must => $filter } }
}
},
{ term => { 'maturity' => 'released' } },
],
must_not => [
{ term => { status => 'backpan' } },
{ term => { distribution => 'perl' } }
]
}
},
},
}
};
bool => {
must => [
{
nested => {
path => 'module',
query => { bool => { must => $filter } }
}
},
{ term => { 'maturity' => 'released' } },
],
must_not => [
{ term => { status => 'backpan' } },
{ term => { distribution => 'perl' } }
]
}
},
},
}

sub _queue_latest ( $dist = $distribution ) {
Expand Down Expand Up @@ -326,19 +321,14 @@ ( $bulk, $source, $status )
my $scroll = $es_file->scroll(
body => {
query => {
filtered => {
query => { match_all => {} },
filter => {
bool => {
must => [
{
term =>
{ 'release' => $source->{release} }
},
{ term => { 'author' => $source->{author} } },
],
bool => {
must => [
{
term =>
{ 'release' => $source->{release} }
},
},
{ term => { 'author' => $source->{author} } },
],
},
},
fields => [qw< name >],
Expand Down
19 changes: 10 additions & 9 deletions bin/release.pl
Original file line number Diff line number Diff line change
Expand Up @@ -426,17 +426,18 @@ ($document)
my $count = $es->search(
search_type => 'count',
body => {
query => { match_all => {} },
filter => {
and => [
{ term => { distribution => $document->{distribution} } },
{
range => {
version_numified =>
query => {
bool => {
must => [
{ term => { distribution => $document->{distribution} } },
{
range => {
version_numified =>
{ 'lt' => $document->{version_numified} }
},
},
}
],
],
},
},
},
)->{hits}{total};
Expand Down
42 changes: 23 additions & 19 deletions bin/tickets.pl
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,30 @@ ()
my $scroll_release = $es_release->scroll(
body => {
query => {
and => [
{ term => { status => 'latest' } },
{
or => [
{
prefix => {
"resources.bugtracker.web" =>
'http://github.com/'
}
bool => {
must => [
{ term => { status => 'latest' } },
{
bool => {
should => [
{
prefix => {
"resources.bugtracker.web" =>
'http://github.com/'
},
},
{
prefix => {
"resources.bugtracker.web" =>
'https://github.com/'
},
},
],
},
{
prefix => {
"resources.bugtracker.web" =>
'https://github.com/'
}
},
],
}
],
}
},
],
},
},
},
);

Expand Down
67 changes: 31 additions & 36 deletions bin/watcher.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,13 @@ ()
fields => [qw< author archive >],
body => {
query => {
filtered => {
query => { match_all => {} },
filter => {
not => {
filter => { term => { status => 'backpan' } }
}
}
}
}
}
bool => {
must_not => [
{ term => { status => 'backpan' } }
],
},
},
},
);

my @changes;
Expand Down Expand Up @@ -168,14 +165,15 @@ ($info)
my $scroll_release = $es_release->scroll(
scroll => '1m',
body => {
query => { match_all => {} },
filter => {
and => [
{ term => { author => $info->cpanid } },
{ term => { archive => $info->filename } },
]
query => {
bool => {
must => [
{ term => { author => $info->cpanid } },
{ term => { archive => $info->filename } },
],
},
},
}
},
);

return $scroll_release->next;
Expand All @@ -193,25 +191,22 @@ ($release)
fields => [qw< _parent _source >],
body => {
query => {
filtered => {
query => { match_all => {} },
filter => {
and => [
{
term => {
release => $release->{_source}{name}
}
},
{
term => {
author => $release->{_source}{author}
}
},
]
}
}
}
}
bool => {
must => [
{
term => {
release => $release->{_source}{name}
}
},
{
term => {
author => $release->{_source}{author}
}
},
],
},
},
},
} );
return if $dry_run;

Expand Down