Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Last active March 2, 2019 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkulekci/24bd377dd1d366081c5c5648d74fa52c to your computer and use it in GitHub Desktop.
Save hkulekci/24bd377dd1d366081c5c5648d74fa52c to your computer and use it in GitHub Desktop.
Elasticsearch Dynamic Templates Example
DELETE products

PUT products
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "product": {
      "dynamic_templates": [
        {
          "strings": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "keyword"
            }
          }
        }
      ]
    }
  }
}


GET products/_mapping


POST products/product
{
  "color": "red",
  "type": "Type A"
}

POST products/product
{
  "color": "blue",
  "type": "Type B",
  "unit": "cm"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment