@@ -62,7 +62,8 @@ static Map<String, FieldSpecificMatcher> matchers(
6262 put ("geo_shape" , new ExactMatcher ("geo_shape" , actualMappings , actualSettings , expectedMappings , expectedSettings ));
6363 put ("shape" , new ExactMatcher ("shape" , actualMappings , actualSettings , expectedMappings , expectedSettings ));
6464 put ("geo_point" , new GeoPointMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings ));
65- put ("text" , new TextMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings ));
65+ put ("text" , new TextMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings , false ));
66+ put ("match_only_text" , new TextMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings , true ));
6667 put ("ip" , new IpMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings ));
6768 put ("constant_keyword" , new ConstantKeywordMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings ));
6869 put ("wildcard" , new WildcardMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings ));
@@ -608,17 +609,20 @@ class TextMatcher implements FieldSpecificMatcher {
608609 private final Settings .Builder actualSettings ;
609610 private final XContentBuilder expectedMappings ;
610611 private final Settings .Builder expectedSettings ;
612+ private final boolean isMatchOnlyText ;
611613
612614 TextMatcher (
613615 XContentBuilder actualMappings ,
614616 Settings .Builder actualSettings ,
615617 XContentBuilder expectedMappings ,
616- Settings .Builder expectedSettings
618+ Settings .Builder expectedSettings ,
619+ boolean isMatchOnlyText
617620 ) {
618621 this .actualMappings = actualMappings ;
619622 this .actualSettings = actualSettings ;
620623 this .expectedMappings = expectedMappings ;
621624 this .expectedSettings = expectedSettings ;
625+ this .isMatchOnlyText = isMatchOnlyText ;
622626 }
623627
624628 @ Override
@@ -640,23 +644,24 @@ public MatchResult match(
640644 // In some cases synthetic source for text fields is synthesized using the keyword multi field.
641645 // So in this case it's appropriate to match it using keyword matching logic (mainly to cover `null_value`).
642646 var multiFields = (Map <String , Object >) getMappingParameter ("fields" , actualMapping , expectedMapping );
643- if (multiFields != null ) {
647+ if (multiFields != null && multiFields . containsKey ( "subfield_keyword" ) ) {
644648 var keywordMatcher = new KeywordMatcher (actualMappings , actualSettings , expectedMappings , expectedSettings );
645649
646- var keywordFieldMapping = (Map <String , Object >) multiFields .get ("kwd " );
650+ var keywordFieldMapping = (Map <String , Object >) multiFields .get ("subfield_keyword " );
647651 var keywordMatchResult = keywordMatcher .match (actual , expected , keywordFieldMapping , keywordFieldMapping );
648652 if (keywordMatchResult .isMatch ()) {
649653 return MatchResult .match ();
650654 }
651655 }
652656
657+ var typeName = isMatchOnlyText ? "match_only_text" : "text" ;
653658 return MatchResult .noMatch (
654659 formatErrorMessage (
655660 actualMappings ,
656661 actualSettings ,
657662 expectedMappings ,
658663 expectedSettings ,
659- "Values of type [text ] don't match, " + prettyPrintCollections (actual , expected )
664+ "Values of type [" + typeName + " ] don't match, " + prettyPrintCollections (actual , expected )
660665 )
661666 );
662667 }
0 commit comments