Skip to content

mapping script #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ EOT

COPY bin bin
COPY lib lib
COPY conf conf
COPY *.conf .

ENV PERL5LIB="/app/local/lib/perl5:/app/lib" PATH="/app/local/bin:${PATH}"
Expand Down
2 changes: 1 addition & 1 deletion bin/backup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
);

# setup
my $home = path( home() );
my $home = home();

run_restore() if $restore;
run_purge() if $purge;
Expand Down
2 changes: 0 additions & 2 deletions bin/cpan_testers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
);

# setup

# XXX fix hardcoded path
my $home = home();

my $db
Expand Down
32 changes: 32 additions & 0 deletions bin/mapping.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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(
"index=s" => \$index,
"cmd=s" => \$cmd,
);
die "cmd can only be one of: 'create', 'delete'\n"
unless grep { $cmd eq $_ } qw< create delete >;

# setup
my $type = $index;

my $mapper = MetaCPAN::Mapper->new();

$mapper->index_delete($index)
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);
}
45 changes: 45 additions & 0 deletions conf/es/account/mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"dynamic": false,
"properties": {
"access_token": {
"dynamic": true,
"properties": {
"client": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"token": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
},
"code": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"id": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"identity": {
"dynamic": false,
"properties": {
"key": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"name": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
}
}
}
8 changes: 8 additions & 0 deletions conf/es/account/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mapper": {
"dynamic": "false"
},
"number_of_replicas": 1,
"number_of_shards": 1,
"refresh_interval": "1s"
}
157 changes: 157 additions & 0 deletions conf/es/author/mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"dynamic": false,
"properties": {
"asciiname": {
"fields": {
"analyzed": {
"analyzer": "standard",
"fielddata": {
"format": "disabled"
},
"store": true,
"type": "string"
}
},
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"blog": {
"dynamic": true,
"properties": {
"feed": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"url": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
},
"city": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"country": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"donation": {
"dynamic": true,
"properties": {
"id": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"name": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
},
"email": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"gravatar_url": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"is_pause_custodial_account": {
"type": "boolean"
},
"location": {
"type": "geo_point"
},
"name": {
"fields": {
"analyzed": {
"analyzer": "standard",
"fielddata": {
"format": "disabled"
},
"store": true,
"type": "string"
}
},
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"pauseid": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"perlmongers": {
"dynamic": true,
"properties": {
"name": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"url": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
},
"profile": {
"dynamic": false,
"include_in_root": true,
"properties": {
"id": {
"fields": {
"analyzed": {
"analyzer": "simple",
"fielddata": {
"format": "disabled"
},
"store": true,
"type": "string"
}
},
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"name": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
},
"type": "nested"
},
"region": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"updated": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"user": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"website": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
}
8 changes: 8 additions & 0 deletions conf/es/author/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mapper": {
"dynamic": "false"
},
"number_of_replicas": 1,
"number_of_shards": 1,
"refresh_interval": "1s"
}
35 changes: 35 additions & 0 deletions conf/es/contributor/mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"dynamic": false,
"properties": {
"distribution": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"pauseid": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"name": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"email": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"release_author": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"release_name": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
}
8 changes: 8 additions & 0 deletions conf/es/contributor/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mapper": {
"dynamic": "false"
},
"number_of_replicas": 1,
"number_of_shards": 1,
"refresh_interval": "1s"
}
40 changes: 40 additions & 0 deletions conf/es/cover/mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"dynamic": false,
"properties": {
"criteria": {
"dynamic": true,
"properties": {
"branch": {
"type": "float"
},
"condition": {
"type": "float"
},
"statement": {
"type": "float"
},
"subroutine": {
"type": "float"
},
"total": {
"type": "float"
}
}
},
"distribution": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"release": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
},
"version": {
"ignore_above": 2048,
"index": "not_analyzed",
"type": "string"
}
}
}
8 changes: 8 additions & 0 deletions conf/es/cover/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mapper": {
"dynamic": "false"
},
"number_of_replicas": 1,
"number_of_shards": 1,
"refresh_interval": "1s"
}
Loading