Skip to content

Commit

Permalink
Merge pull request #631 from metacpan/mickey/revert_query_changes
Browse files Browse the repository at this point in the history
Revert "simplify multi-value term queries (using 'terms')"
  • Loading branch information
mickeyn committed May 9, 2017
2 parents a626491 + 34f063e commit 4ac0127
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
8 changes: 7 additions & 1 deletion lib/MetaCPAN/Document/Release.pm
Expand Up @@ -313,7 +313,13 @@ sub aggregate_status_by_author {

sub find_depending_on {
my ( $self, $modules ) = @_;
return $self->filter( { terms => { 'dependency.module' => $modules } } );
return $self->filter(
{
or => [
map { { term => { 'dependency.module' => $_ } } } @$modules
]
}
);
}

sub find {
Expand Down
34 changes: 24 additions & 10 deletions lib/MetaCPAN/Model/Search.pm
Expand Up @@ -32,11 +32,9 @@ my @ROGUE_DISTRIBUTIONS
= qw(kurila perl_debug perl_mlb perl-5.005_02+apache1.3.3+modperl pod2texi perlbench spodcxx Bundle-Everything);

sub _not_rogue {
return {
not => {
filter => { terms => { distribution => \@ROGUE_DISTRIBUTIONS } }
}
};
my @rogue_dists
= map { { term => { 'distribution' => $_ } } } @ROGUE_DISTRIBUTIONS;
return { not => { filter => { or => \@rogue_dists } } };
}

sub search_simple {
Expand Down Expand Up @@ -170,8 +168,17 @@ sub _search_collapsed {
size => 5000,
query => {
filtered => {
filter =>
{ terms => { 'distribution' => \@distributions } }
filter => {
and => [
{
or => [
map {
{ term => { 'distribution' => $_ } }
} @distributions
]
}
]
}
}
}
}
Expand Down Expand Up @@ -376,7 +383,9 @@ sub _build_search_descriptions_query {
query => {
filtered => {
query => { match_all => {} },
filter => { terms => { id => \@ids } },
filter => {
or => [ map { { term => { id => $_ } } } @ids ]
}
}
},
fields => [qw(description id)],
Expand Down Expand Up @@ -409,8 +418,13 @@ sub _build_search_favorites_query {
size => 0,
query => {
filtered => {
query => { match_all => {} },
filter => { terms => { distribution => \@distributions } },
query => { match_all => {} },
filter => {
or => [
map { { term => { 'distribution' => $_ } } }
@distributions
]
}
}
},
aggregations => {
Expand Down
8 changes: 7 additions & 1 deletion lib/MetaCPAN/Server/Controller/Changes.pm
Expand Up @@ -62,7 +62,13 @@ sub get : Chained('index') : PathPart('') : Args(2) {
and => [
{ term => { level => 0 } },
{ term => { directory => 0 } },
{ terms => { name => \@candidates } },
{
or => [
map {
{ term => { 'name' => $_ } }
} @candidates
]
}
]
}
],
Expand Down

0 comments on commit 4ac0127

Please sign in to comment.