Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Last active February 12, 2019 22:49
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/8236619aa9db1cd603cfb05fd1478b4f to your computer and use it in GitHub Desktop.
Save hkulekci/8236619aa9db1cd603cfb05fd1478b4f to your computer and use it in GitHub Desktop.
Index Preparing For Medium Blog
DELETE products

PUT products
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "product": {
      "properties": {
        "id": {
          "type": "keyword"
        },
        "colour": {
          "type": "keyword",
          "index": true
        },
        "categories": {
          "properties": {
            "id": {
              "type": "integer"
            },
            "name": {
              "type": "keyword",
              "index": true
            }
          }
        },
        "name": {
          "type": "text",
          "index": true
        }
      }
    }
  }
}



POST products/product
{
  "id": "a1",
  "name": "Test Product 1",
  "colour": "red",
  "categories": [
    {
      "id": 1,
      "name": "Cat 1"
    },
    {
      "id": 2,
      "name": "Cat 2"
    }
  ]
}


POST products/product
{
  "id": "a2",
  "name": "Test Product 2",
  "colour": "red",
  "categories": [
    {
      "id": 2,
      "name": "Cat 2"
    },
    {
      "id": 3,
      "name": "Cat 3"
    }
  ]
}


POST products/product
{
  "id": "a3",
  "name": "Test Product 3",
  "colour": "white",
  "categories": [
    {
      "id": 3,
      "name": "Cat 3"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment