# Elasticsearch mapping generator

Paste JSON and generate an Elasticsearch mapping with text/keyword fields, date and numeric detection, nested arrays, ip, geo_point, and create-index output.

## Run it

- **CLI:** `gizza tool elasticsearch-mapping-generator '{"id": 1, "title": "Hello", "published_at": "2026-01-02T03:04:05Z", "views": 42}'`
- **Web:** https://gizza.ai/tools/elasticsearch-mapping-generator/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/elasticsearch-mapping-generator/tool.json

## Inputs

- `json` — Sample JSON document (or an array of documents) _(field)_
- `output` — Output shape _(field)_
- `text_fields` — String fields _(field)_
- `ignore_above` — ignore_above for keyword fields (0 = omit) _(field)_
- `analyzer` — Analyzer for text fields (blank = standard) _(field)_
- `integer_type` — Whole-number type _(field)_
- `float_type` — Fractional-number type _(field)_
- `date_detection` — Detect date strings _(field)_
- `numeric_detection` — Detect numbers written as strings _(field)_
- `detect_ip` — Detect IPv4/IPv6 addresses as ip fields _(field)_
- `detect_geo_point` — Detect {lat, lon} objects as geo_point _(field)_
- `array_objects` — Arrays of objects _(field)_
- `dynamic` — Policy for fields not in the sample _(field)_
- `shards` — number_of_shards (create-index only) _(field)_
- `replicas` — number_of_replicas (create-index only) _(field)_

## Output

- Mapping (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `json` — Sample JSON document (or an array of documents)
- `output` — Output shape
- `text_fields` — String fields
- `ignore_above` — ignore_above for keyword fields (0 = omit)
- `analyzer` — Analyzer for text fields (blank = standard)
- `integer_type` — Whole-number type
- `float_type` — Fractional-number type
- `date_detection` — Detect date strings
- `numeric_detection` — Detect numbers written as strings
- `detect_ip` — Detect IPv4/IPv6 addresses as ip fields
- `detect_geo_point` — Detect {lat, lon} objects as geo_point
- `array_objects` — Arrays of objects
- `dynamic` — Policy for fields not in the sample
- `shards` — number_of_shards (create-index only)
- `replicas` — number_of_replicas (create-index only)

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`

---

## About this tool

Paste one representative JSON document, or an array of sample documents, and this tool infers a deterministic Elasticsearch mapping. It follows Elasticsearch dynamic mapping as the baseline, then makes the common production choices explicit: text plus `.keyword` fields, date detection, numeric-string detection, `nested` arrays, `ip` fields, `geo_point` objects, dynamic-field policy, and an optional create-index wrapper with shard and replica settings.

Example input:

```json
{"id":1,"title":"Hello world","published_at":"2026-01-02T03:04:05Z","views":42,"rating":4.5,"tags":["search","mapping"]}
```

With the default settings, the output includes `id` as `long`, `published_at` as `date`, `views` as `long`, `rating` as `float`, and `title` as a `text` field with a `keyword` sub-field. Use the output-shape menu when you need only `properties`, a `{ "mappings": ... }` body, or a full create-index body with `settings`.

Limits and edge cases: the input must be valid JSON with an object or an array of objects at the root. Empty arrays and `null` values do not create fields. Multiple samples are merged field-by-field; integer plus fractional observations widen to the configured float type, while incompatible observations fall back to the selected string strategy. The generator emits the modern typeless mapping shape used by current Elasticsearch versions; legacy mapping-type wrappers are intentionally not generated.

## FAQ

<details>
<summary>Does this exactly match Elasticsearch dynamic mapping?</summary>

It uses Elasticsearch dynamic mapping as the default mental model, but it is more conservative when several samples disagree. Elasticsearch decides from the first observed value in an index; this tool merges all supplied samples so `42` plus `4.5` becomes the configured float type, and incompatible shapes become the selected string field strategy instead of silently choosing the first type.

</details>

<details>
<summary>When should I choose `nested` instead of `object` for arrays?</summary>

Keep the default `object` when flattened arrays are acceptable and you want the same behavior Elasticsearch uses by default. Choose `nested` when each object in the array must be queried as its own unit, such as matching a line-item `sku` and `qty` from the same order line. Nested fields are more precise for those queries, but they add indexing and query overhead.

</details>

<details>
<summary>Why are per-field manual overrides not in the form?</summary>

The public page uses a single declarative parameter form, so a full editable field table would be awkward and easy to desynchronize from the generated JSON. Generate the closest mapping here, then edit individual fields in your editor before sending the body to Elasticsearch.

</details>

<details>
<summary>Which Elasticsearch versions is the output for?</summary>

The output is the modern typeless mapping shape used by current Elasticsearch releases. Older clusters that require mapping-type wrappers need a small manual wrapper around the generated `properties`; the inference itself is still useful, but this tool does not emit legacy type names.

</details>

## Related tools

- [Strip accents and transliterate text to plain ASCII](https://gizza.ai/tools/accent-stripper/): Paste text and strip accents to plain ASCII. Transliterate non-Latin scripts, preserve chosen characters, lowercase, and audit unmapped output.
- [Brotli Decompress](https://gizza.ai/tools/brotli-decompress/): Paste a Brotli (.br) payload as Base64 or hex and read what's inside. Output as text, hex, or Base64, with size and ratio stats. Free, private, no sign-up.
- [Child Growth Percentile Calculator](https://gizza.ai/tools/child-growth-percentile/): Compute CDC child growth-chart percentiles and z-scores from age, sex, height, weight and head circumference. Supports metric or US units.
- [Dependency Risk Auditor](https://gizza.ai/tools/dependency-risk-auditor/): Audit a package.json, package-lock.json, yarn.lock or pnpm-lock.yaml for wildcard versions, git/URL deps, install scripts and missing integrity hashes.
- [DNA / RNA Reverse Complement](https://gizza.ai/tools/dna-reverse-complement/): Reverse-complement DNA or RNA in your browser — full IUPAC ambiguity codes, FASTA records, preserved case, complement-only and reverse-only modes. No upload.
