File tree Expand file tree Collapse file tree 5 files changed +21
-32
lines changed Expand file tree Collapse file tree 5 files changed +21
-32
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use Mojo::Base 'Mojolicious::Plugin';
5
5
use Carp ();
6
6
7
7
# Models from the catalyst app
8
- use MetaCPAN::Model ::Search ();
8
+ use MetaCPAN::Query ::Search ();
9
9
10
10
# New models
11
11
use MetaCPAN::API::Model::Cover ();
@@ -21,9 +21,9 @@ has download => sub {
21
21
22
22
has search => sub {
23
23
my $self = shift ;
24
- return MetaCPAN::Model ::Search-> new(
25
- es => $self -> app-> es,
26
- index => ' cpan' ,
24
+ return MetaCPAN::Query ::Search-> new(
25
+ es => $self -> app-> es,
26
+ index_name => ' cpan' ,
27
27
);
28
28
};
29
29
Original file line number Diff line number Diff line change 1
- package MetaCPAN::Model ::Search ;
1
+ package MetaCPAN::Query ::Search ;
2
2
3
3
use MetaCPAN::Moose;
4
4
@@ -10,18 +10,7 @@ use MetaCPAN::Types::TypeTiny qw( Object Str );
10
10
use MetaCPAN::Util qw( single_valued_arrayref_to_scalar true false ) ;
11
11
use MooseX::StrictConstructor;
12
12
13
- has es => (
14
- is => ' ro' ,
15
- isa => Object,
16
- handles => { _run_query => ' search' , },
17
- required => 1,
18
- );
19
-
20
- has index => (
21
- is => ' ro' ,
22
- isa => Str,
23
- required => 1,
24
- );
13
+ with ' MetaCPAN::Query::Role::Common' ;
25
14
26
15
const my $RESULTS_PER_RUN => 200;
27
16
const my @ROGUE_DISTRIBUTIONS => qw(
@@ -368,8 +357,8 @@ sub build_query {
368
357
369
358
sub run_query {
370
359
my ( $self , $type , $es_query ) = @_ ;
371
- return $self -> _run_query (
372
- index => $self -> index ,
360
+ return $self -> es -> search (
361
+ index => $self -> index_name ,
373
362
type => $type ,
374
363
body => $es_query ,
375
364
search_type => ' dfs_query_then_fetch' ,
Original file line number Diff line number Diff line change @@ -4,20 +4,20 @@ use strict;
4
4
use warnings;
5
5
6
6
use Moose;
7
- use MetaCPAN::Model ::Search ();
7
+ use MetaCPAN::Query ::Search ();
8
8
9
9
extends ' MetaCPAN::Server::Model::CPAN' ;
10
10
11
11
has search => (
12
12
is => ' ro' ,
13
- isa => ' MetaCPAN::Model ::Search' ,
13
+ isa => ' MetaCPAN::Query ::Search' ,
14
14
lazy => 1,
15
15
handles => [qw( search_for_first_result search_web ) ],
16
16
default => sub {
17
17
my $self = shift ;
18
- return MetaCPAN::Model ::Search-> new(
19
- es => $self -> es,
20
- index => $self -> index ,
18
+ return MetaCPAN::Query ::Search-> new(
19
+ es => $self -> es,
20
+ index_name => $self -> index ,
21
21
);
22
22
},
23
23
);
Original file line number Diff line number Diff line change @@ -2,17 +2,17 @@ use strict;
2
2
use warnings;
3
3
use lib ' t/lib' ;
4
4
5
- use MetaCPAN::Model ::Search ();
5
+ use MetaCPAN::Query ::Search ();
6
6
use MetaCPAN::TestServer ();
7
7
use MetaCPAN::Util qw( true false) ;
8
8
use Test::Deep qw( cmp_deeply ignore ) ;
9
9
use Test::More;
10
10
11
11
# Just use this to get an es object.
12
12
my $server = MetaCPAN::TestServer-> new;
13
- my $search = MetaCPAN::Model ::Search-> new(
14
- es => $server -> es_client,
15
- index => ' cpan' ,
13
+ my $search = MetaCPAN::Query ::Search-> new(
14
+ es => $server -> es_client,
15
+ index_name => ' cpan' ,
16
16
);
17
17
18
18
ok( $search , ' search' );
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ use lib 't/lib';
5
5
# USE `bin/prove_live` to run this
6
6
# READ the README.txt in this dir
7
7
8
- use MetaCPAN::Model ::Search ();
8
+ use MetaCPAN::Query ::Search ();
9
9
use MetaCPAN::TestServer ();
10
10
use Test::More;
11
11
12
12
# Just use this to get an es object.
13
13
my $server = MetaCPAN::TestServer-> new;
14
- my $search = MetaCPAN::Model ::Search-> new(
15
- es => $server -> es_client,
16
- index => ' cpan' ,
14
+ my $search = MetaCPAN::Query ::Search-> new(
15
+ es => $server -> es_client,
16
+ index_name => ' cpan' ,
17
17
);
18
18
19
19
my %tests = (
You can’t perform that action at this time.
0 commit comments