Exercises 25 - 31


We will use a bit more of Elasticsearch’s query DSL in this round of labs, and then use the enrich processor to add details of the National Olympic Committee.

This is the last round of exercises using the Olympics data. I encourage you to continue learning with the data.

If you enjoyed the exercises, please let me know. I’ll be posting solutions soon.


Exercise 25

Write a query to return the first 50 documents for gold medal athletics events, in descending age order.

Exercise 26

Write a query to match swimming events where either:

Enhance the query so the results identify whether the weight, age, or both matched the search criteria.

Exercise 27

Create a new index for the National Olympic Committees. Call it olympic-noc-regions, with 1 primary shard and 0 replica shards. Ensure it has the following fields:

Exercise 28

Index the data containing information about the National Olympic Committees using the Bulk API by following these steps:

  1. Download the ND-JSON file from here.

  2. Run the following command on the terminal:

    curl -s -H "Content-Type: application/x-ndjson" --data-binary "@olympic-nocs.ndjson" http://localhost:9200/olympic-noc-regions/_bulk

Validate that the data was indexed correctly. The index should be green and contain 230 documents.

Exercise 29

Create an enrich policy and ingest pipeline that uses the enrich processor to add details of the National Olympic Committee to each document in the olympic-events-fixed index. Call the policy olympic-noc-append and the pipeline enrich-noc. Add details of the matching NOC entry to a new field called nocDetails, matching on the noc field.

Exercise 30

Create a new index called olympic-events-enriched, into which we can reindex the Olympic events but with some enriched fields. Change the mapping settings for the new index so we can add fields dynamically.

Exercise 31

Reindex the olympic-events-fixed index into olympic-events-enriched, running it through the enrich-noc ingest pipeline. Once complete, verify the new field was added to the olympic-events-fixed index, and populated with details of the associated NOC.