Skip to content

Commit 07b6a84

Browse files
author
Dmytro Koval
committed
Add default variant for Normalizer
1 parent 2d0e3a5 commit 07b6a84

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/Normalizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected static void setupNormalizerDeserializer(ObjectDeserializer<Builder> op
199199
op.add(Builder::custom, CustomNormalizer._DESERIALIZER, "custom");
200200
op.add(Builder::lowercase, LowercaseNormalizer._DESERIALIZER, "lowercase");
201201

202-
op.setTypeProperty("type", null);
202+
op.setTypeProperty("type", "custom");
203203

204204
}
205205

java-client/src/test/java/co/elastic/clients/elasticsearch/model/VariantsTest.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package co.elastic.clients.elasticsearch.model;
2121

2222
import co.elastic.clients.elasticsearch._types.analysis.Analyzer;
23+
import co.elastic.clients.elasticsearch._types.analysis.Normalizer;
2324
import co.elastic.clients.elasticsearch._types.mapping.Property;
2425
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
2526
import co.elastic.clients.elasticsearch._types.query_dsl.FunctionScore;
@@ -107,7 +108,7 @@ public void testInternalTag() {
107108
}
108109

109110
@Test
110-
public void testDefaultInternalTag() {
111+
public void testDefaultInternalTagForAnalyzer() {
111112

112113
Consumer<String> test = s -> {
113114
Analyzer a = fromJson(s, Analyzer.class);
@@ -124,6 +125,23 @@ public void testDefaultInternalTag() {
124125
test.accept("{\"filter\":[\"some-filter\"],\"tokenizer\":\"some-tokenizer\"}");
125126
}
126127

128+
@Test
129+
public void testDefaultInternalTagForNormalizer() {
130+
131+
Consumer<String> test = s -> {
132+
Normalizer normalizer = fromJson(s, Normalizer.class);
133+
assertEquals(Normalizer.Kind.Custom, normalizer._kind());
134+
assertEquals("some-filter", normalizer.custom().filter().get(0));
135+
assertEquals("some-char-filter", normalizer.custom().charFilter().get(0));
136+
};
137+
138+
// Explicit type
139+
test.accept("{\"type\":\"custom\",\"filter\":[\"some-filter\"],\"char_filter\":[\"some-char-filter\"]}");
140+
141+
// Default type
142+
test.accept("{\"filter\":[\"some-filter\"],\"char_filter\":[\"some-char-filter\"]}");
143+
}
144+
127145
@Test
128146
public void testBuilders() {
129147
String json = "{\"exists\":{\"field\":\"foo\"}}";

0 commit comments

Comments
 (0)