Mappings

  • text is analyzed for full-text search; keyword keeps the exact value for filters, sorting, and aggregations.
  • Arrays use their element mapping; object flattens arrays of objects while nested preserves each element's field relationships.
  • Change an existing field type by creating a correctly mapped index and reindexing the documents.

Create an index and example document

PUT /products-v1
{
  "mappings": {
    "dynamic": "strict",
    "properties": {
      "id": { "type": "keyword" },
      "name": {
        "type": "text",
        "fields": {
          "keyword": { "type": "keyword", "ignore_above": 256 }
        }
      },
      "description": { "type": "text" },
      "active": { "type": "boolean" },
      "quantity": { "type": "integer" },
      "total_views": { "type": "long" },
      "price": { "type": "scaled_float", "scaling_factor": 100 },
      "rating": { "type": "double" },
      "created_at": { "type": "date", "format": "strict_date_optional_time||epoch_millis" },
      "source_ip": { "type": "ip" },
      "tags": { "type": "keyword" },
      "scores": { "type": "float" },
      "dimensions": {
        "type": "object",
        "properties": {
          "height_cm": { "type": "double" },
          "width_cm": { "type": "double" }
        }
      },
      "contacts": {
        "type": "object",
        "properties": {
          "type": { "type": "keyword" },
          "value": { "type": "keyword" }
        }
      },
      "variants": {
        "type": "nested",
        "properties": {
          "sku": { "type": "keyword" },
          "color": { "type": "keyword" },
          "price": { "type": "scaled_float", "scaling_factor": 100 }
        }
      },
      "metadata": { "type": "flattened" },
      "location": { "type": "geo_point" },
      "payload": { "type": "binary" }
    }
  }
}

POST /products-v1/_doc/product-42
{
  "id": "product-42",
  "name": "Mechanical Keyboard",
  "description": "Low-profile wireless keyboard",
  "active": true,
  "quantity": 120,
  "total_views": 98420,
  "price": 129.99,
  "rating": 4.8,
  "created_at": "2026-09-04T12:00:00Z",
  "source_ip": "203.0.113.42",
  "tags": ["hardware", "wireless"],
  "scores": [0.91, 0.87, 0.82],
  "dimensions": {
    "height_cm": 2.1,
    "width_cm": 35.4
  },
  "contacts": [
    { "type": "email", "value": "[email protected]" },
    { "type": "phone", "value": "+48-22-555-0100" }
  ],
  "variants": [
    { "sku": "KB-BLACK", "color": "black", "price": 129.99 },
    { "sku": "KB-WHITE", "color": "white", "price": 134.99 }
  ],
  "metadata": {
    "warehouse": "waw-1",
    "campaign": "autumn"
  },
  "location": { "lat": 52.2297, "lon": 21.0122 },
  "payload": "SGVsbG8gV29ybGQ="
}

Limits

# Maximum mapped fields; raising it increases mapping and query memory cost.
PUT /products-v1/_settings
{
  "index.mapping.total_fields.limit": 1000
}

# Maximum distinct nested mappings in the index.
PUT /products-v1/_settings
{
  "index.mapping.nested_fields.limit": 50
}

# Maximum nested objects inside one document.
PUT /products-v1/_settings
{
  "index.mapping.nested_objects.limit": 10000
}