Skip to content

Commit 54e12ca

Browse files
authored
Merge pull request #14 from metacpan/mickey/filtered_query_body
fix filtered query body
2 parents f87324f + c5a12e0 commit 54e12ca

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

bin/latest.pl

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ sub run {
8484
# 'file' type records where the module.name matches the
8585
# distribution name and which are released &
8686
# indexed (the 'leading' module)
87-
my $q_body = _filtered_query($filter);
87+
my $q_body = _body_filtered_query($filter);
8888

8989
my $node = config->{config}{es_test_node};
9090
my $es = MetaCPAN::ES->new( type => "file", node => $node );
@@ -95,12 +95,11 @@ sub run {
9595
qw< author date distribution download_url module.name release status >
9696
],
9797
);
98-
9998
$found_total += $scroll->total;
10099

101100
log_debug { sprintf( "Found %s modules", $scroll->total ) };
102101
log_debug { sprintf( "Found %s total modules", $found_total ) }
103-
if @$filter != $total and $filter == $module_filters->[-1];
102+
if @$filter != $total and $filter == $module_filters->[-1];
104103
exit;
105104

106105
my $i = 0;
@@ -201,27 +200,29 @@ ($filter)
201200
return \@module_filters;
202201
}
203202

204-
sub _filtered_query ($filter) {
203+
sub _body_filtered_query ($filter) {
205204
return +{
206-
filtered => {
207-
filter => {
208-
bool => {
209-
must => [
210-
{
211-
nested => {
212-
path => 'module',
213-
filter => { bool => { must => $filter } }
214-
}
215-
},
216-
{ term => { 'maturity' => 'released' } },
217-
],
218-
must_not => [
219-
{ term => { status => 'backpan' } },
220-
{ term => { distribution => 'perl' } }
221-
]
222-
}
205+
query => {
206+
filtered => {
207+
query => { match_all => {} },
208+
filter => {
209+
bool => {
210+
must => [
211+
{
212+
nested => {
213+
path => 'module',
214+
query => { bool => { must => $filter } }
215+
}
216+
},
217+
{ term => { 'maturity' => 'released' } },
218+
],
219+
must_not => [
220+
{ term => { status => 'backpan' } },
221+
{ term => { distribution => 'perl' } }
222+
]
223+
}
224+
},
223225
},
224-
query => { match_all => {} },
225226
}
226227
};
227228
}

lib/MetaCPAN/ES.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ sub scroll ( $self, %args ) {
9999
);
100100
}
101101

102-
sub count {
103-
my ( $self, %args ) = @_;
102+
sub count ( $self, %args ) {
104103
return $self->{es}->count(
105104
index => $self->{index},
106105
type => $self->{type},

0 commit comments

Comments
 (0)