@@ -105,4 +105,38 @@ public void testMappedMismatch() throws IOException {
105105 var sut = new SourceMatcher (mapping , Settings .builder (), mapping , Settings .builder (), actual , expected , false );
106106 assertFalse (sut .match ().isMatch ());
107107 }
108+
109+ public void testCountedKeywordMatch () throws IOException {
110+ List <Map <String , Object >> actual = List .of (Map .of ("field" , List .of ("a" , "b" , "a" , "c" , "b" , "a" )));
111+ List <Map <String , Object >> expected = List .of (Map .of ("field" , List .of ("a" , "b" , "a" , "c" , "b" , "a" )));
112+
113+ var mapping = XContentBuilder .builder (XContentType .JSON .xContent ());
114+ mapping .startObject ();
115+ mapping .startObject ("_doc" );
116+ {
117+ mapping .startObject ("field" ).field ("type" , "counted_keyword" ).endObject ();
118+ }
119+ mapping .endObject ();
120+ mapping .endObject ();
121+
122+ var sut = new SourceMatcher (mapping , Settings .builder (), mapping , Settings .builder (), actual , expected , false );
123+ assertTrue (sut .match ().isMatch ());
124+ }
125+
126+ public void testCountedKeywordMismatch () throws IOException {
127+ List <Map <String , Object >> actual = List .of (Map .of ("field" , List .of ("a" , "b" , "a" , "c" , "b" , "a" )));
128+ List <Map <String , Object >> expected = List .of (Map .of ("field" , List .of ("a" , "b" , "c" , "a" )));
129+
130+ var mapping = XContentBuilder .builder (XContentType .JSON .xContent ());
131+ mapping .startObject ();
132+ mapping .startObject ("_doc" );
133+ {
134+ mapping .startObject ("field" ).field ("type" , "counted_keyword" ).endObject ();
135+ }
136+ mapping .endObject ();
137+ mapping .endObject ();
138+
139+ var sut = new SourceMatcher (mapping , Settings .builder (), mapping , Settings .builder (), actual , expected , false );
140+ assertFalse (sut .match ().isMatch ());
141+ }
108142}
0 commit comments