Elasticsearch 7.13: Search Templates Guide


Kacper Bąk
2 min readSep 30, 2023

Search is critical in the airline industry. From looking up flights to sorting them based on various criteria, Elasticsearch provides a powerful toolset. This guide walks you through creating a search template in Elasticsearch 7.13 for an airline’s flight data.


Before you start, ensure you have access to an Elasticsearch and Kibana instance. Log in to Kibana using your credentials.

Screenshot: Kibana Login Screen
Screenshot: Kibana Login Screen

Creating the flights_template Search Template

  1. Open the Kibana Console.
  2. Create a new search template called flights_template.

Here’s a code snippet:

PUT _scripts/flights_template
"script": {
"lang": "mustache",
"source": {
"from": "{{from}}{{^from}}0{{/from}}",
"size": "{{size}}{{^size}}25{{/size}}",
"query": {
"bool": {
"must": [
"wildcard": {
"Carrier": {
"value": "{{carrier}}{{^carrier}}*{{/carrier}}",
"case_insensitive": true
"wildcard": {
"OriginCityName": {
"value": "{{origin}}{{^origin}}*{{/origin}}"…