Core
Framework v2.x
2

mappings() #

Available since 2.14.0

Loads mappings into the app.

This method is idempotent. If a collection mappings is defined multiple times, only the last definition will be retained.

This method can only be used before the application is started.

Copied to clipboard!
mappings(mappings: JSONObject): void

Argument Type Description
mappings
JSONObject
Object containing index and their collection mappings.

Usage #

Copied to clipboard!
app.import.mappings({
  index1: {
    collection1: {
      mappings: {
        dynamic: 'strict',
        _meta: {
          field: 'value',
        },
        properties: {
          fieldA: { type: 'keyword'},
          fieldB: { type: 'integer'}
        },
      },
      settings: {
        analysis : {
          analyzer:{
            content:{
              type:'custom',
              tokenizer:'whitespace'
            }
          }
        }
      }
    },
    collection2: {
      mappings: {
        properties: {
          fieldC: {
            type: 'keyword'
          }
        }
      }
    },
  },
  index2: {
    collection1: {
      mappings: {
        properties: {
          fieldD: {
            type: 'integer'
          }
        }
      }
    },
  },
})