Skip to content

Commit fd97599

Browse files
authored
DATAES-946 - Support 'wildcard' field type.
Original PR: #571
1 parent 80a50a8 commit fd97599

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

Diff for: src/main/java/org/springframework/data/elasticsearch/annotations/FieldType.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ public enum FieldType {
5555
/** @since 4.1 */
5656
Rank_Feature, //
5757
/** @since 4.1 */
58-
Rank_Features //
58+
Rank_Features, //
59+
/** since 4.2 */
60+
Wildcard //
5961
}

Diff for: src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java

+15
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,15 @@ void shouldWriteCorrectTermVectorValues() {
257257
IndexOperations indexOps = operations.indexOps(TermVectorFieldEntity.class);
258258
indexOps.create();
259259
indexOps.putMapping();
260+
}
261+
262+
@Test // DATAES-946
263+
@DisplayName("should write wildcard field mapping")
264+
void shouldWriteWildcardFieldMapping() {
260265

266+
IndexOperations indexOps = operations.indexOps(WildcardEntity.class);
267+
indexOps.create();
268+
indexOps.putMapping();
261269
}
262270

263271
/**
@@ -647,4 +655,11 @@ static class TermVectorFieldEntity {
647655
@Field(type = FieldType.Text,
648656
termVector = TermVector.with_positions_offsets_payloads) private String with_positions_offsets_payloads;
649657
}
658+
659+
@Data
660+
@Document(indexName = "wildcard-test")
661+
static class WildcardEntity {
662+
@Nullable @Field(type = Wildcard) private String wildcardWithoutParams;
663+
@Nullable @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams;
664+
}
650665
}

Diff for: src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public void shouldUseIgnoreAbove() throws JSONException {
305305
assertEquals(expected, mapping, false);
306306
}
307307

308-
@Test // DATAES-621, DATAES-943
308+
@Test // DATAES-621, DATAES-943, DATAES-946
309309
public void shouldSetFieldMappingProperties() throws JSONException {
310310
String expected = "{\n" + //
311311
" \"properties\": {\n" + //
@@ -399,6 +399,14 @@ public void shouldSetFieldMappingProperties() throws JSONException {
399399
" },\n" + //
400400
" \"eagerGlobalOrdinalsFalse\": {\n" + //
401401
" \"type\": \"text\"\n" + //
402+
" },\n" + //
403+
" \"wildcardWithoutParams\": {\n" + //
404+
" \"type\": \"wildcard\"\n" + //
405+
" },\n" + //
406+
" \"wildcardWithParams\": {\n" + //
407+
" \"type\": \"wildcard\",\n" + //
408+
" \"null_value\": \"WILD\",\n" + //
409+
" \"ignore_above\": 42\n" + //
402410
" }\n" + //
403411
" }\n" + //
404412
"}\n"; //
@@ -891,6 +899,8 @@ static class FieldMappingParameters {
891899
@Nullable @Field(type = Object, enabled = false) private String disabledObject;
892900
@Nullable @Field(type = Text, eagerGlobalOrdinals = true) private String eagerGlobalOrdinalsTrue;
893901
@Nullable @Field(type = Text, eagerGlobalOrdinals = false) private String eagerGlobalOrdinalsFalse;
902+
@Nullable @Field(type = Wildcard) private String wildcardWithoutParams;
903+
@Nullable @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams;
894904
}
895905

896906
@Document(indexName = "test-index-configure-dynamic-mapping")
@@ -945,12 +955,10 @@ static class EntityWithSeqNoPrimaryTerm {
945955

946956
@Data
947957
static class RankFeatureEntity {
948-
@Id private String id;
949958

959+
@Id private String id;
950960
@Field(type = FieldType.Rank_Feature) private Integer pageRank;
951-
952961
@Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength;
953-
954962
@Field(type = FieldType.Rank_Features) private Map<String, Integer> topics;
955963
}
956964
}

0 commit comments

Comments
 (0)