Skip to content

Commit

Permalink
Added spec + tests for the GetFieldMapping API
Browse files Browse the repository at this point in the history
Introduced in elastic#3941
  • Loading branch information
bleskes authored and brusic committed Jan 19, 2014
1 parent 853fe19 commit aea151d
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rest-api-spec/api/indices.get_field_mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"indices.get_mapping": {
"documentation": "http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/",
"methods": ["GET"],
"url": {
"path": "/_mapping/field/{field}",
"paths": ["/_mapping/field/{field}", "/{index}/_mapping/field/{field}", "/{index}/{type}/_mapping/field/{field}"],
"parts": {
"index": {
"type" : "list",
"description" : "A comma-separated list of index names"
},
"type": {
"type" : "list",
"description" : "A comma-separated list of document types"
},
"field": {
"type" : "list",
"description" : "A comma-separated list of fields"
}
},
"params": {
"include_defaults": {
"type" : "boolean",
"description" : "specifies default mapping values should be returned"
}
}
},
"body": null
}
}
68 changes: 68 additions & 0 deletions rest-api-spec/test/indices.get_field_mapping/10_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
setup:
- skip:
version: "0 - 0.90.5"
reason: "get field mapping was added in 0.90.6"

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

---
"Get field mapping with no index and type":
- do:
indices.get_field_mapping:
field: text

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

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

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

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

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

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

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

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

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

---
"Get field mapping with include_defaults":

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

- match: {test_index.test_type.text.mapping.text.type: string}
- match: {test_index.test_type.text.mapping.text.analyzer: default}
24 changes: 24 additions & 0 deletions rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
"Raise 404 when field doesn't exist":
- skip:
version: "0 - 0.90.5"
reason: "get field mapping was added in 0.90.6"

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

- do:
catch: missing
indices.get_field_mapping:
index: test_index
type: test_type
field: not_text

24 changes: 24 additions & 0 deletions rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
"Raise 404 when type doesn't exist":
- skip:
version: "0 - 0.90.5"
reason: "get field mapping was added in 0.90.6"

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

- do:
catch: missing
indices.get_field_mapping:
index: test_index
type: not_test_type
field: text

14 changes: 14 additions & 0 deletions rest-api-spec/test/indices.get_field_mapping/40_missing_index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"Raise 404 when index doesn't exist":
- skip:
version: "0 - 0.90.5"
reason: "get field mapping was added in 0.90.6"

- do:
catch: missing
indices.get_mapping:
index: test_index
type: type
field: field


0 comments on commit aea151d

Please sign in to comment.