###
### Assuming Toshi is running on port 8080
### Create an index for some song lyrics
GET http://{{host}}:{{port}}

###
PUT http://{{host}}:{{port}}/lyrics/_create
Content-Type: application/json

[
  {
    "name": "lyrics",
    "type": "text",
    "options": {
      "indexing": {
        "record": "position",
        "tokenizer": "default"
      },
      "stored": true
    }
  },
  {
    "name": "year",
    "type": "i64",
    "options": {
      "indexed": true,
      "stored": true
    }
  },
  {
    "name": "idx",
    "type": "u64",
    "options": {
      "indexed": true,
      "stored": true
    }
  },
  {
    "name": "artist",
    "type": "text",
    "options": {
      "indexing": {
        "record": "position",
        "tokenizer": "default"
      },
      "stored": true
    }
  },
  {
    "name": "genre",
    "type": "text",
    "options": {
      "indexing": {
        "record": "position",
        "tokenizer": "default"
      },
      "stored": true
    }
  },
  {
    "name": "song",
    "type": "text",
    "options": {
      "indexing": {
        "record": "position",
        "tokenizer": "default"
      },
      "stored": true
    }
  }
]

### Get the schema summary back to see the index was created
GET {{host}}:{{port}}/lyrics/_summary?include_sizes=true
Content-Type: application/JSON

### Add a single song to the index
PUT http://{{host}}:{{port}}/lyrics/
Content-Type: application/json

{
  "options": {
    "commit": false
  },
  "document": {
    "song": "he-still-loves-me-f-choir-from-fighting-temptations",
    "year": 2007,
    "artist": "beyonce-knowles",
    "genre": "Pop",
    "lyrics": "Took me a while but I'm finally here",
    "idx": 23
  }
}

### List the indexes
GET http://{{host}}:{{port}}/_list
Content-Type: application/json

### Force a commit if necessary at any time
GET http://{{host}}:{{port}}/lyrics/_flush
Accept: application/json

### Get that document back from the engine
GET http://{{host}}:{{port}}/lyrics/
Content-Type: application/json

### Test Term Query
POST http://{{host}}:{{port}}/lyrics/
Content-Type: application/JSON

{
  "query": {
    "term": {
      "lyrics": "me"
    }
  },
  "limit": 1
}
