Skip to content

Commit ec54fa8

Browse files
committed
mapping compare: ignore string fields converted to text/keyword fields
Elasticsearch 5 will automatically convert string mapping types to be text or keyword types. We want to support both ES 2.4 and 5, so keep the declared mappings using the string type. When we check this against what is deployed, ignore the difference if a string is converted to text or keyword.
1 parent 95265d2 commit ec54fa8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/MetaCPAN/Script/Mapping.pm

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,24 @@ sub _compare_mapping {
688688
}
689689
}
690690
else { # Scalar Value
691-
if ( $deploy_value ne $model_value ) {
691+
if (
692+
$sfield eq 'type'
693+
&& $model_value eq 'string'
694+
&& ( $deploy_value eq 'text'
695+
|| $deploy_value eq 'keyword' )
696+
)
697+
{
698+
# ES5 automatically converts string types to text
699+
# or keyword. once we upgrade to ES5 and update
700+
# our mappings, this special case can be removed.
701+
}
702+
elsif ($sfield eq 'index'
703+
&& $model_value eq 'no'
704+
&& $deploy_value eq 'false' )
705+
{
706+
# another ES5 string automatic conversion
707+
}
708+
elsif ( $deploy_value ne $model_value ) {
692709
log_error {
693710
'Mismatch field: '
694711
. $sname . '.'

0 commit comments

Comments
 (0)