Context examplesedit

To run the examples, index the sample seat data into Elasticsearch. The examples must be run sequentially to work correctly.

  1. Download the seat data. This data set contains booking information for a collection of plays. Each document represents a single seat for a play at a particular theater on a specific date and time.

    Each document contains the following fields:

    theatre (keyword)
    The name of the theater the play is in.
    play (text)
    The name of the play.
    actors (text)
    A list of actors in the play.
    row (integer)
    The row of the seat.
    number (integer)
    The number of the seat within a row.
    cost (double)
    The cost of the ticket for the seat.
    sold (boolean)
    Whether or not the seat is sold.
    datetime (date)
    The date and time of the play as a date object.
    date (keyword)
    The date of the play as a keyword.
    time (keyword)
    The time of the play as a keyword.
  2. Start Elasticsearch. Note these examples assume Elasticsearch and Kibana are running locally. To use the Console editor with a remote Kibana instance, click the settings icon and enter the Console URL. To submit a cURL request to a remote Elasticsearch instance, edit the request URL.
  3. Create mappings for the sample data:

    PUT /seats
      "mappings": {
        "properties": {
          "theatre":  { "type": "keyword" },
          "play":     { "type": "keyword" },
          "actors":   { "type": "text"    },
          "row":      { "type": "integer" },
          "number":   { "type": "integer" },
          "cost":     { "type": "double"  },
          "sold":     { "type": "boolean" },
          "datetime": { "type": "date"    },
          "date":     { "type": "keyword" },
          "time":     { "type": "keyword" }
  4. Run the ingest processor context example. This sets up a script ingest processor used on each document as the seat data is indexed.
  5. Index the seat data:

    curl -XPOST "localhost:9200/seats/_bulk?pipeline=seats" -H "Content-Type: application/x-ndjson" --data-binary "@/<local-file-path>/seats.json"