Object field type

    Create a mapping with an object field:

    Index a document with an object field:

    1. PUT testindex1/_doc/1
    2. {
    3. "patient": {
    4. "name" : "John Doe",
    5. "id" : "123456"
    6. }
    7. }

    Nested objects are stored as flat key/value pairs internally. To refer to a field in a nested object, use parent field.child field (for example, patient.id).

    Parameters

    The following table lists the parameters accepted by object field types. All parameters are optional.

    The dynamic parameter specifies whether new fields can be dynamically added to an object that is already indexed.

    For example, you can initially create a mapping with a patient object that has only one field:

    1. PUT testindex1/_mappings
    2. {
    3. "properties": {
    4. "patient": {
    5. "properties" :
    6. "name" : {
    7. "type" : "text"
    8. }
    9. }
    10. }
    11. }
    12. }

    As a result, the field id is added to the mappings:

    1. {
    2. "testindex1" : {
    3. "mappings" : {
    4. "properties" : {
    5. "patient" : {
    6. "id" : {
    7. "type" : "text",
    8. "keyword" : {
    9. "type" : "keyword",
    10. "ignore_above" : 256
    11. }
    12. }
    13. },
    14. "name" : {
    15. "type" : "text"
    16. }
    17. }
    18. }
    19. }
    20. }
    21. }
    22. }

    The dynamic parameter has the following valid values.

    ValueDescription
    trueNew fields can be added to the mapping dynamically. This is the default.
    falseNew fields cannot be added to the mapping dynamically. If a new field is detected, it is not indexed or searchable. However, it is still retrievable from the _source field.
    strictWhen new fields are added to the mapping dynamically, an exception is thrown. To add a new field to an object, you have to add it to the mapping first.

    Inner objects inherit the dynamic parameter value from their parent unless they declare their own parameter value.