Solutions 25 - 31

Solution 25

GET olympic-events-fixed/_search
{
  "size": 50,
  "query": {
    "term": {
      "medal": {
        "value": "Gold"
      }
    }
  },
  "sort": [
    {
      "age": {
        "order": "desc"
      }
    }
  ]
}

Solution 26

GET olympic-events-fixed/_search
{
  "size": 50,
  "query": {
    "bool": {
      "filter": {
        "term": {
          "sport": {
            "value": "Swimming"
          }
        }
      },
      "should": [
        {
          "range": {
            "weight": {
              "_name": "weight",
              "gte": 50,
              "lte": 55
            }
          }
        },
        {
          "range": {
            "age": {
              "_name": "age",
              "gt": 30
            }
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

Solution 27

Step through the same instructions for Exercise 01 but using the file for the NOCs, and saving into a new index called olympic-noc-regions.

Solution 28

Change the number of replicas to zero:

PUT olympic-noc-regions/_settings
{
  "number_of_replicas": 0
}

Then validate the index status:

GET _cat/indices/olympic-noc-regions?v

Solution 29

Create the enrich policy:

PUT _enrich/policy/olympic-noc
{
  "match": {
    "indices": "olympic-noc-regions",
    "match_field": "noc",
    "enrich_fields": ["region", "notes"]
  }
}

Create the enrich index:

POST _enrich/policy/olympic-noc-append/_execute

Create the enrich pipeline:

PUT _ingest/pipeline/enrich-noc
{
  "processors": [
    {
      "enrich": {
        "policy_name": "olympic-noc-append",
        "field": "noc",
        "target_field": "nocDetails"
      }
    }
  ]
}

Solution 30

Create a new index using the index template:

PUT olympic-events-enriched

Then change the dynamic setting for the mapping to be true instead of strict:

PUT olympic-events-enriched/_mapping
{
  "dynamic": "true"
}

Solution 31

Run all documents in the index through the pipeline:

POST _reindex
{
  "source": {
    "index": "olympic-events-fixed"
  },
  "dest": {
    "index": "olympic-events-enriched",
    "pipeline": "enrich-noc"
  }
}
Licensed under CC BY-NC-SA 4.0
All content on this site is my own and does not necessarily reflect the views of any of my employers or clients, past or present.
Built with Hugo
Theme based on Stack originally designed by Jimmy, forked by George Bridgeman