Skip to content

Commit

Permalink
Support include_type_name in the field mapping and index template API…
Browse files Browse the repository at this point in the history
…s. (#37210)

* Add include_type_name to the get field mappings API.
* Make sure the API specification lists include_type_name as a boolean.
* Add include_type_name to the get index templates API.
* Add include_type_name to the put index templates API.
  • Loading branch information
jtibshirani committed Jan 10, 2019
1 parent 9de62f1 commit a433c40
Show file tree
Hide file tree
Showing 26 changed files with 811 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"params": {
"include_type_name": {
"type" : "string",
"type" : "boolean",
"description" : "Whether a type should be expected in the body of the mappings."
},
"wait_for_active_shards": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
}
},
"params": {
"include_type_name": {
"type" : "boolean",
"description" : "Whether a type should be returned in the body of the mappings."
},
"include_defaults": {
"type" : "boolean",
"description" : "Whether the default mapping values should be returned as well"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"params": {
"include_type_name": {
"type" : "string",
"type" : "boolean",
"description" : "Whether to add the type name to the response"
},
"ignore_unavailable": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
}
},
"params": {
"include_type_name": {
"type" : "boolean",
"description" : "Whether a type should be returned in the body of the mappings."
},
"flat_settings": {
"type": "boolean",
"description": "Return settings in flat format (default: false)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"params": {
"include_type_name": {
"type" : "string",
"type" : "boolean",
"description" : "Whether a type should be expected in the body of the mappings."
},
"timeout": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
}
},
"params": {
"include_type_name": {
"type" : "boolean",
"description" : "Whether a type should be returned in the body of the mappings."
},
"order": {
"type" : "number",
"description" : "The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,76 +1,59 @@
---
setup:
- skip:
version: " - 6.99.99"
reason: include_type_name is not supported before 7.0.0
- do:
indices.create:
include_type_name: false
index: test_index
body:
mappings:
test_type:
properties:
text:
type: text
properties:
text:
type: text

---
"Get field mapping with no index and type":
"Get field mapping with no index":

- do:
indices.get_field_mapping:
include_type_name: false
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}
- match: {test_index.mappings.text.mapping.text.type: text}

---
"Get field mapping by index only":
- do:
indices.get_field_mapping:
include_type_name: false
index: test_index
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}
- match: {test_index.mappings.text.mapping.text.type: text}

---
"Get field mapping by type & field":
"Get field mapping by field, with another field that doesn't exist":

- do:
indices.get_field_mapping:
include_type_name: false
index: test_index
type: test_type
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}

---
"Get field mapping by type & field, with another field that doesn't exist":

- do:
indices.get_field_mapping:
index: test_index
type: test_type
fields: [ text , text1 ]

- match: {test_index.mappings.test_type.text.mapping.text.type: text}
- match: {test_index.mappings.text.mapping.text.type: text}
- is_false: test_index.mappings.test_type.text1

---
"Get field mapping with include_defaults":

- do:
indices.get_field_mapping:
include_type_name: false
index: test_index
type: test_type
fields: text
include_defaults: true

- match: {test_index.mappings.test_type.text.mapping.text.type: text}
- match: {test_index.mappings.test_type.text.mapping.text.analyzer: default}

---
"Get field mapping should work without index specifying type and fields":

- do:
indices.get_field_mapping:
type: test_type
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}

- match: {test_index.mappings.text.mapping.text.type: text}
- match: {test_index.mappings.text.mapping.text.analyzer: default}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
setup:
- do:
indices.create:
index: test_index
body:
mappings:
test_type:
properties:
text:
type: text

---
"Get field mapping with no index and type":

- do:
indices.get_field_mapping:
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}

---
"Get field mapping by index only":
- do:
indices.get_field_mapping:
index: test_index
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}

---
"Get field mapping by type & field":

- do:
indices.get_field_mapping:
index: test_index
type: test_type
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}

---
"Get field mapping by type & field, with another field that doesn't exist":

- do:
indices.get_field_mapping:
index: test_index
type: test_type
fields: [ text , text1 ]

- match: {test_index.mappings.test_type.text.mapping.text.type: text}
- is_false: test_index.mappings.test_type.text1

---
"Get field mapping with include_defaults":

- do:
indices.get_field_mapping:
index: test_index
type: test_type
fields: text
include_defaults: true

- match: {test_index.mappings.test_type.text.mapping.text.type: text}
- match: {test_index.mappings.test_type.text.mapping.text.analyzer: default}

---
"Get field mapping should work without index specifying type and fields":

- do:
indices.get_field_mapping:
type: test_type
fields: text

- match: {test_index.mappings.test_type.text.mapping.text.type: text}

Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
---
"Return empty object if field doesn't exist, but type and index do":

- skip:
version: " - 6.99.99"
reason: types are required in requests before 7.0.0
- do:
indices.create:
include_type_name: false
index: test_index
body:
mappings:
test_type:
properties:
text:
type: text
analyzer: whitespace
mappings:
properties:
text:
type: text
analyzer: whitespace

- do:
indices.get_field_mapping:
index: test_index
type: test_type
fields: not_existent
- match: { '': {}}

- match: { 'test_index.mappings': {}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"Return empty object if field doesn't exist, but type and index do":

- do:
indices.create:
index: test_index
body:
mappings:
test_type:
properties:
text:
type: text
analyzer: whitespace

- do:
indices.get_field_mapping:
index: test_index
type: test_type
fields: not_existent

- match: { '': {}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
catch: missing
indices.get_field_mapping:
index: test_index
type: type
fields: field


Loading

0 comments on commit a433c40

Please sign in to comment.