{
  "slug": "elasticsearch-mapping-generator",
  "name": "gizza-ai/elasticsearch-mapping-generator",
  "version": "0.1.0",
  "title": "Elasticsearch mapping generator — JSON sample to index mapping — gizza.ai",
  "description": "Paste JSON and generate an Elasticsearch mapping with text/keyword fields, date and numeric detection, nested arrays, ip, geo_point, and create-index output.",
  "tags": [
    "elasticsearch mapping generator",
    "json to elasticsearch mapping",
    "index mapping",
    "create index body",
    "nested vs object",
    "text keyword multi-field"
  ],
  "category": "utilities",
  "urls": {
    "page": "https://gizza.ai/tools/elasticsearch-mapping-generator/",
    "markdown": "https://gizza.ai/tools/elasticsearch-mapping-generator/index.md",
    "descriptor": "https://gizza.ai/tools/elasticsearch-mapping-generator/tool.json",
    "deep_link_example": "https://gizza.ai/tools/elasticsearch-mapping-generator/?json=%7B%22id%22%3A%201%2C%20%22title%22%3A%20%22Hello%22%2C%20%22published_at%22%3A%20%222026-01-02T03%3A04%3A05Z%22%2C%20%22views%22%3A%2042%7D&output=mappings&text_fields=text_keyword&ignore_above=256&analyzer=english&integer_type=long&float_type=float&date_detection=true&numeric_detection=true&detect_ip=true&detect_geo_point=true&array_objects=object&dynamic=true&shards=1&replicas=1"
  },
  "cli": "gizza tool elasticsearch-mapping-generator '{\"id\": 1, \"title\": \"Hello\", \"published_at\": \"2026-01-02T03:04:05Z\", \"views\": 42}'",
  "tool": {
    "description": "Infer an Elasticsearch index mapping from a sample JSON document, or from a JSON array of documents which are merged field by field. Follows Elasticsearch's own dynamic mapping rules as the baseline: booleans map to boolean, whole numbers to long, fractional numbers to float, objects recurse into object + properties, arrays take their element type, and null values and empty arrays add no field. Strings become text with a .keyword sub-field (ignore_above 256) unless date detection (on by default, ISO-8601 and slash dates) or numeric detection (off by default) claims them. Options: output (mappings default, create-index for a full PUT body with shards/replicas, or properties only), text_fields (text_keyword default, keyword, text), ignore_above, analyzer for text fields, integer_type/float_type widths, date_detection, numeric_detection, detect_ip (IPv4/IPv6 to the ip type), detect_geo_point ({lat,lon} objects to geo_point), array_objects (object default or nested) and dynamic (true default, false, strict, runtime). Returns the pretty-printed mapping JSON with properties sorted alphabetically.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "analyzer": {
          "default": "",
          "description": "Analyzer name to set on every text field, e.g. 'english', 'french' or a custom analyzer you define in the index settings. Empty (default) leaves the standard analyzer in place. Ignored when text_fields is 'keyword'.",
          "type": "string"
        },
        "array_objects": {
          "default": "object",
          "description": "How an array of objects is mapped. 'object' (default) matches Elasticsearch and flattens the array, so two sub-fields can match across DIFFERENT elements. 'nested' indexes each element separately so nested queries match within one element, at a higher indexing cost.",
          "enum": [
            "object",
            "nested"
          ],
          "type": "string"
        },
        "date_detection": {
          "default": true,
          "description": "Map strings that look like dates to the 'date' type. Default true (matches Elasticsearch). Recognises ISO-8601 (2020-01-02, 2020-01-02T03:04:05Z, with optional fraction and offset) and slash dates (2020/01/02), which also get an explicit format. Turn off to keep every string as text/keyword.",
          "type": "boolean"
        },
        "detect_geo_point": {
          "default": false,
          "description": "Map objects that hold exactly a numeric 'lat' and 'lon' to the 'geo_point' type instead of an object with two number fields. Default false. Enables geo distance/bounding-box queries.",
          "type": "boolean"
        },
        "detect_ip": {
          "default": false,
          "description": "Map strings that are valid IPv4/IPv6 addresses to the 'ip' type, which supports CIDR range queries. Default false. Elasticsearch's dynamic mapping never does this, so it is off unless you ask.",
          "type": "boolean"
        },
        "dynamic": {
          "default": "true",
          "description": "Policy for fields that were not in the sample. 'true' (default) maps and indexes them; 'false' stores them without indexing; 'strict' rejects documents containing them; 'runtime' adds them as runtime fields, queryable but not indexed.",
          "enum": [
            "true",
            "false",
            "strict",
            "runtime"
          ],
          "type": "string"
        },
        "float_type": {
          "default": "float",
          "description": "Elasticsearch type for fractional numbers. 'float' (default) matches dynamic mapping; 'double' for higher precision, 'half_float' for compact low-precision values such as scores.",
          "enum": [
            "float",
            "double",
            "half_float"
          ],
          "type": "string"
        },
        "ignore_above": {
          "default": 256,
          "description": "Maximum string length indexed by keyword fields; longer values are stored but not indexed. Default 256 (Elasticsearch's own default). Use 0 to omit ignore_above entirely. Only applies when text_fields includes keyword.",
          "maximum": 32766,
          "minimum": 0,
          "type": "integer"
        },
        "integer_type": {
          "default": "long",
          "description": "Elasticsearch type for whole numbers. 'long' (default) matches dynamic mapping; 'integer' or 'short' save space when you know the value range.",
          "enum": [
            "long",
            "integer",
            "short"
          ],
          "type": "string"
        },
        "json": {
          "description": "A sample JSON document to infer the mapping from, e.g. {\"id\":1,\"title\":\"Hello\"}. Pass a JSON ARRAY of documents to merge several samples: every key seen in any document is mapped, and a field seen as both a whole and a fractional number widens to the float type.",
          "type": "string"
        },
        "numeric_detection": {
          "default": false,
          "description": "Map strings that hold numbers (\"42\", \"3.14\") to the numeric types instead of text. Default false, matching Elasticsearch. Date detection is applied first.",
          "type": "boolean"
        },
        "output": {
          "default": "mappings",
          "description": "What to wrap the inferred fields in. 'mappings' (default) emits {\"mappings\":{...}}; 'create-index' adds a settings block with shards/replicas so the whole body can be PUT to create an index; 'properties' emits only {\"properties\":{...}}.",
          "enum": [
            "mappings",
            "create-index",
            "properties"
          ],
          "type": "string"
        },
        "replicas": {
          "default": 1,
          "description": "number_of_replicas for the settings block. Default 1; use 0 for a single-node development cluster. Only used when output is 'create-index'.",
          "maximum": 100,
          "minimum": 0,
          "type": "integer"
        },
        "shards": {
          "default": 1,
          "description": "number_of_shards for the settings block. Default 1. Only used when output is 'create-index'.",
          "maximum": 1024,
          "minimum": 1,
          "type": "integer"
        },
        "text_fields": {
          "default": "text_keyword",
          "description": "How plain strings are mapped. 'text_keyword' (default) is Elasticsearch's own choice: a 'text' field with a '.keyword' sub-field for exact matching, sorting and aggregations. 'keyword' emits an exact-match-only field; 'text' emits a full-text-only field.",
          "enum": [
            "text_keyword",
            "keyword",
            "text"
          ],
          "type": "string"
        }
      },
      "required": [
        "json"
      ],
      "type": "object"
    }
  }
}