Skip to content

Commit 382e795

Browse files
committed
Add include_type_name to the get field mappings API.
1 parent 7a43634 commit 382e795

File tree

12 files changed

+403
-121
lines changed

12 files changed

+403
-121
lines changed

rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_field_mapping.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
}
2222
},
2323
"params": {
24+
"include_type_name": {
25+
"type" : "boolean",
26+
"description" : "Whether a type should be returned in the body of the mappings."
27+
},
2428
"include_defaults": {
2529
"type" : "boolean",
2630
"description" : "Whether the default mapping values should be returned as well"
Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,59 @@
11
---
22
setup:
3+
- skip:
4+
version: " - 6.99.99"
5+
reason: include_type_name is not supported before 7.0.0
36
- do:
47
indices.create:
8+
include_type_name: false
59
index: test_index
610
body:
711
mappings:
8-
test_type:
9-
properties:
10-
text:
11-
type: text
12+
properties:
13+
text:
14+
type: text
1215

1316
---
14-
"Get field mapping with no index and type":
17+
"Get field mapping with no index":
1518

1619
- do:
1720
indices.get_field_mapping:
21+
include_type_name: false
1822
fields: text
1923

20-
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
24+
- match: {test_index.mappings.text.mapping.text.type: text}
2125

2226
---
2327
"Get field mapping by index only":
2428
- do:
2529
indices.get_field_mapping:
30+
include_type_name: false
2631
index: test_index
2732
fields: text
2833

29-
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
34+
- match: {test_index.mappings.text.mapping.text.type: text}
3035

3136
---
32-
"Get field mapping by type & field":
37+
"Get field mapping by field, with another field that doesn't exist":
3338

3439
- do:
3540
indices.get_field_mapping:
41+
include_type_name: false
3642
index: test_index
37-
type: test_type
38-
fields: text
39-
40-
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
41-
42-
---
43-
"Get field mapping by type & field, with another field that doesn't exist":
44-
45-
- do:
46-
indices.get_field_mapping:
47-
index: test_index
48-
type: test_type
4943
fields: [ text , text1 ]
5044

51-
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
45+
- match: {test_index.mappings.text.mapping.text.type: text}
5246
- is_false: test_index.mappings.test_type.text1
5347

5448
---
5549
"Get field mapping with include_defaults":
5650

5751
- do:
5852
indices.get_field_mapping:
53+
include_type_name: false
5954
index: test_index
60-
type: test_type
6155
fields: text
6256
include_defaults: true
6357

64-
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
65-
- match: {test_index.mappings.test_type.text.mapping.text.analyzer: default}
66-
67-
---
68-
"Get field mapping should work without index specifying type and fields":
69-
70-
- do:
71-
indices.get_field_mapping:
72-
type: test_type
73-
fields: text
74-
75-
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
76-
58+
- match: {test_index.mappings.text.mapping.text.type: text}
59+
- match: {test_index.mappings.text.mapping.text.analyzer: default}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
setup:
3+
- do:
4+
indices.create:
5+
index: test_index
6+
body:
7+
mappings:
8+
test_type:
9+
properties:
10+
text:
11+
type: text
12+
13+
---
14+
"Get field mapping with no index and type":
15+
16+
- do:
17+
indices.get_field_mapping:
18+
fields: text
19+
20+
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
21+
22+
---
23+
"Get field mapping by index only":
24+
- do:
25+
indices.get_field_mapping:
26+
index: test_index
27+
fields: text
28+
29+
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
30+
31+
---
32+
"Get field mapping by type & field":
33+
34+
- do:
35+
indices.get_field_mapping:
36+
index: test_index
37+
type: test_type
38+
fields: text
39+
40+
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
41+
42+
---
43+
"Get field mapping by type & field, with another field that doesn't exist":
44+
45+
- do:
46+
indices.get_field_mapping:
47+
index: test_index
48+
type: test_type
49+
fields: [ text , text1 ]
50+
51+
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
52+
- is_false: test_index.mappings.test_type.text1
53+
54+
---
55+
"Get field mapping with include_defaults":
56+
57+
- do:
58+
indices.get_field_mapping:
59+
index: test_index
60+
type: test_type
61+
fields: text
62+
include_defaults: true
63+
64+
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
65+
- match: {test_index.mappings.test_type.text.mapping.text.analyzer: default}
66+
67+
---
68+
"Get field mapping should work without index specifying type and fields":
69+
70+
- do:
71+
indices.get_field_mapping:
72+
type: test_type
73+
fields: text
74+
75+
- match: {test_index.mappings.test_type.text.mapping.text.type: text}
76+
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
---
22
"Return empty object if field doesn't exist, but type and index do":
3-
3+
- skip:
4+
version: " - 6.99.99"
5+
reason: types are required in requests before 7.0.0
46
- do:
57
indices.create:
8+
include_type_name: false
69
index: test_index
710
body:
8-
mappings:
9-
test_type:
10-
properties:
11-
text:
12-
type: text
13-
analyzer: whitespace
11+
mappings:
12+
properties:
13+
text:
14+
type: text
15+
analyzer: whitespace
1416

1517
- do:
1618
indices.get_field_mapping:
1719
index: test_index
18-
type: test_type
1920
fields: not_existent
20-
21-
- match: { '': {}}
21+
22+
- match: { 'test_index.mappings': {}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
"Return empty object if field doesn't exist, but type and index do":
3+
4+
- do:
5+
indices.create:
6+
index: test_index
7+
body:
8+
mappings:
9+
test_type:
10+
properties:
11+
text:
12+
type: text
13+
analyzer: whitespace
14+
15+
- do:
16+
indices.get_field_mapping:
17+
index: test_index
18+
type: test_type
19+
fields: not_existent
20+
21+
- match: { '': {}}

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/40_missing_index.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
catch: missing
66
indices.get_field_mapping:
77
index: test_index
8-
type: type
98
fields: field
109

1110

0 commit comments

Comments
 (0)