Skip to content

Commit

Permalink
Merge pull request #3704 from 10up/fix/issue-3611-remove-old-mappings
Browse files Browse the repository at this point in the history
Remove Old mappings
  • Loading branch information
felipeelia authored Oct 24, 2023
2 parents 8a4a379 + bbb8d99 commit 24b619a
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 1,464 deletions.
8 changes: 3 additions & 5 deletions includes/classes/Indexable/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,12 +703,10 @@ public function generate_mapping() {

$es_version = (string) $es_version;

$mapping_file = 'initial.php';
$mapping_file = '7-0.php';

if ( version_compare( $es_version, '5.0', '<' ) ) {
$mapping_file = 'pre-5-0.php';
} elseif ( version_compare( $es_version, '7.0', '>=' ) ) {
$mapping_file = '7-0.php';
if ( version_compare( $es_version, '7.0', '<' ) ) {
$mapping_file = 'initial.php';
}

/**
Expand Down
30 changes: 2 additions & 28 deletions includes/classes/Indexable/Post/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,10 @@ public function get_mapping_name() {
}
$es_version = (string) $es_version;

$mapping_file = '5-2.php';
$mapping_file = '7-0.php';

if ( ! $es_version || version_compare( $es_version, '5.0' ) < 0 ) {
$mapping_file = 'pre-5-0.php';
} elseif ( version_compare( $es_version, '5.0', '>=' ) && version_compare( $es_version, '5.2', '<' ) ) {
$mapping_file = '5-0.php';
} elseif ( version_compare( $es_version, '5.2', '>=' ) && version_compare( $es_version, '7.0', '<' ) ) {
if ( version_compare( $es_version, '7.0', '<' ) ) {
$mapping_file = '5-2.php';
} elseif ( version_compare( $es_version, '7.0', '>=' ) ) {
$mapping_file = '7-0.php';
}

return apply_filters( 'ep_post_mapping_version', $mapping_file );
Expand Down Expand Up @@ -1425,26 +1419,6 @@ protected function determine_mapping_version_based_on_existing( $mapping, $index
return '5-2.php';
}

/**
* Check for 5-0 mapping.
* `keyword` fields were only made available in ES 5.0
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.0/release-notes-5.0.0.html
*/
if ( 'keyword' === $post_title_sortable['type'] ) {
return '5-0.php';
}

/**
* Check for pre-5-0 mapping.
* `string` fields were deprecated in ES 5.0 in favor of text/keyword
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.0/release-notes-5.0.0.html
*/
if ( 'string' === $post_title_sortable['type'] ) {
return 'pre-5-0.php';
}

return 'unknown';
}

Expand Down
8 changes: 3 additions & 5 deletions includes/classes/Indexable/Term/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,10 @@ public function generate_mapping() {
}
$es_version = (string) $es_version;

$mapping_file = 'initial.php';
$mapping_file = '7-0.php';

if ( version_compare( $es_version, '5.0', '<' ) ) {
$mapping_file = 'pre-5-0.php';
} elseif ( version_compare( $es_version, '7.0', '>=' ) ) {
$mapping_file = '7-0.php';
if ( version_compare( $es_version, '7.0', '<' ) ) {
$mapping_file = 'initial.php';
}

/**
Expand Down
Loading

0 comments on commit 24b619a

Please sign in to comment.