Skip to content
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
8 changes: 1 addition & 7 deletions bin/mapping.pl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use strict;
use warnings;

use Cpanel::JSON::XS qw< decode_json >;
use Getopt::Long;
use MetaCPAN::Mapper;
use MetaCPAN::Ingest qw< home >;

my ( $index, $cmd );
GetOptions(
Expand All @@ -23,10 +21,6 @@
if $mapper->index_exists($index);

if ( $cmd eq 'create' ) {
my $home = home();
my $map_file = $home->child('conf/es/' . $index . '/mapping.json');
my $mapping = decode_json $map_file->slurp();

$mapper->index_create($index);
$mapper->index_put_mapping($index, $type, $mapping);
$mapper->index_add_mapping($index, $type);
}
10 changes: 7 additions & 3 deletions lib/MetaCPAN/Mapper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use strict;
use warnings;
use v5.36;

use Cpanel::JSON::XS qw< decode_json >;
use Path::Tiny qw< path >;
use MetaCPAN::Logger qw< :log :dlog >;
use Search::Elasticsearch;
Expand Down Expand Up @@ -44,9 +45,12 @@ sub index_put_mapping ($self, $index, $type, $mapping) {
);
}

sub get_mapping ($self, $index) {
# my $home = home();
# my $file = $dir->child('');
sub index_add_mapping ($self, $index, $type) {
my $home = home();
my $map_file = $home->child('conf/es/' . $index . '/mapping.json');
my $mapping = decode_json $map_file->slurp();

$self->index_put_mapping($index, $type, $mapping);
}

1;