---
setup:
  - 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.mappings.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.mappings.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.mappings.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.mappings.test_type.text.mapping.text.type:     string}
  - 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
        field: text
        include_defaults: true

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

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

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

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

