Import some dataedit

We will be using the entire collected works of Shakespeare as our example data. In order to make the best use of Kibana you will likely want to apply a mapping to your new index. Let’s create the shakespeare index with the following mapping. Our data will have more fields than this, but these are the ones we want to explicitly map. Specifically we do not want to analyze speaker and play_name. You’ll see why later on.

Run in a terminal:

curl -XPUT http://localhost:9200/shakespeare -d '
{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
   }
  }
 }
}
';

Great, we’ve created the index. Now we want to import the data. You can download the entire works of shakespeare in elasticsearch bulk import format here: shakespeare.json

Import it into your local elasticsearch instance with the following command. This may take a few minutes. Shakespeare wrote a lot of stuff!

curl -XPUT localhost:9200/_bulk --data-binary @shakespeare.json