Skip to content

Commit cf0e6e0

Browse files
committed
cve: ES syntax update for newer version
1 parent ec7c8f5 commit cf0e6e0

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

bin/cve.pl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,31 +134,32 @@
134134

135135
if (@filters) {
136136
my $query = {
137-
query => {
138-
bool => {
139-
must => [
140-
{ term => { distribution => $dist } }, @filters,
141-
]
142-
}
143-
},
137+
bool => {
138+
must => [
139+
{ term => { distribution => $dist } }, @filters,
140+
]
141+
}
144142
};
145143

146144
my $releases = $es->search(
147145
index => 'cpan',
148146
type => 'release',
149-
body => $query,
150-
fields => [ "version", "name", "author", ],
151-
size => 2000,
147+
body => {
148+
query => $query,
149+
_source => [qw< version name author >],
150+
size => 2000,
151+
},
152152
);
153153

154154
if ( $releases->{hits}{total} ) {
155155
## no critic (ControlStructures::ProhibitMutatingListFunctions)
156156
@matches = map { $_->[0] }
157157
sort { $a->[1] <=> $b->[1] }
158158
map {
159-
my %fields = %{ $_->{fields} };
160-
ref $_ and $_ = $_->[0] for values %fields;
161-
[ \%fields, numify_version( $fields{version} ) ];
159+
[
160+
$_->{_source},
161+
numify_version( $_->{_source}{version} )
162+
]
162163
} @{ $releases->{hits}{hits} };
163164
}
164165
else {

0 commit comments

Comments
 (0)