Elasticsearch+KibanaをMac上で試してみる(サンプルデータ編)


概要

気軽にElasticsearchを試してみたく、Docker Desktop for Macを使用してサクッと起動してみた際の備忘録。
この時点ではどういう点で生きてくるかわからないが、マルチノードのElasticsearchとKibanaを使用。
データは予め準備したりせず、まずはサンプルデータを使用。

公式ページ

Elasticsearch
Kibana

バージョン情報

Elasticsearch: 7.7.0
Docker Desktop for Mac: 2.2.0.3

手順

Docker Desktop for Macをインストール

手順に関してはここで書いておきたい内容とは逸れるため割愛。
公式ページ参照

※ Elasticsearch公式ページの記載より、メモリの割当サイズを最低4GiB以上にする点に注意

Macローカルの任意のディレクトリにdocker-compose.ymlを作成

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data02:/usr/share/elasticsearch/data
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data03:/usr/share/elasticsearch/data
    networks:
      - elastic
  # kibana追加
  kibana:
    image: docker.elastic.co/kibana/kibana:7.7.0
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_HOSTS: http://es01:9200
      MONITORING_ENABLED: "false"
    networks:
      - elastic

volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge

各コンテナのnetworksの指定に注意。この指定がされていないコンテナはコンテナ間の接続ができない。
(実際にKibanaとElasticSearchがうまく繋げなくて躓いた…)

また、ELASTICSEARCH_HOSTSのホスト名は9200ポートで接続ができるコンテナのコンテナ名を指定する。
ここでlocalhostを指定すると、Kibanaが起動しているコンテナ自身を指すことになり接続ができない。

KibanaはOSSイメージではモニタリングプラグインは定義されていないようなので、ここでは何も考えずモニタリングのパラメータは無効に変更。

docker起動

docker-compose up

起動確認

Elasticsearch: http://localhost:9200/
Kibana: http://localhost:5601/

Kibanaを触ってみる

Kibana起動でサンプルデータを使用するかどうか聞かれるため、サンプルデータを追加することでなにも準備しなくてもとりあえず触ることができる。

Elasticsearchを触ってみる

nodeの状態を確認してみる

$ curl -X GET "localhost:9200/_cat/nodes?v&pretty"
ip         heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.18.0.3           40          97   1    0.01    0.04     0.07 dilmrt    -      es03
172.18.0.4           55          97   1    0.01    0.04     0.07 dilmrt    -      es01
172.18.0.2           21          97   1    0.01    0.04     0.07 dilmrt    *      es02

indexの状態を確認してみる

$ curl -X GET "localhost:9200/_cat/indices?v&pretty"
health status index                        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .apm-custom-link             TQKCg6TySuCmT5Mhcu9JOA   1   1          0            0       416b           208b
green  open   kibana_sample_data_ecommerce 7S3IDNXrRqueO6NWhfumyw   1   1       4675            0      9.2mb          4.6mb
green  open   .kibana_task_manager_1       9ZRZB6zIQlOyHj1O2Scc2A   1   1          5            2     74.1kb           37kb
green  open   .apm-agent-configuration     RCktj2mHRVW8Hnsvl6ufdw   1   1          0            0       416b           208b
green  open   .kibana_1                    lvpq1mO8Qx65XJlHG92IUg   1   1         93            0      1.8mb        961.2kb

クラスタの状態を確認してみる

curl -X GET "localhost:9200/_cat/health?v&pretty"
epoch      timestamp cluster           status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1590572784 09:46:24  es-docker-cluster green           3         3     10   5    0    0        0             0                  -                100.0%

全てのドキュメントを取得してみる

curl -H "Content-Type: application/json" -X GET "http://localhost:9200/kibana_sample_data_ecommerce/_search?pretty=true" -d '
{
    "query" : {
        "match_all" : {}
    }
}'
{
  "took" : 8,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4675,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "nS9OVXIBP1shjACtvt7r",
        "_score" : 1.0,
        "_source" : {
          "category" : [
            "Men's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Eddie",
          "customer_full_name" : "Eddie Underwood",
          "customer_gender" : "MALE",
          "customer_id" : 38,
          "customer_last_name" : "Underwood",
          "customer_phone" : "",
          "day_of_week" : "Monday",
          "day_of_week_i" : 0,
          "email" : "[email protected]",
          "manufacturer" : [
            "Elitelligence",
            "Oceanavigations"
          ],
          "order_date" : "2020-06-08T09:28:48+00:00",
          "order_id" : 584677,
          "products" : [
            {
              "base_price" : 11.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Elitelligence",
              "tax_amount" : 0,
              "product_id" : 6283,
              "category" : "Men's Clothing",
              "sku" : "ZO0549605496",
              "taxless_price" : 11.99,
              "unit_discount_amount" : 0,
              "min_price" : 6.35,
              "_id" : "sold_product_584677_6283",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T09:28:48+00:00",
              "product_name" : "Basic T-shirt - dark blue/white",
              "price" : 11.99,
              "taxful_price" : 11.99,
              "base_unit_price" : 11.99
            },
            {
              "base_price" : 24.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Oceanavigations",
              "tax_amount" : 0,
              "product_id" : 19400,
              "category" : "Men's Clothing",
              "sku" : "ZO0299602996",
              "taxless_price" : 24.99,
              "unit_discount_amount" : 0,
              "min_price" : 11.75,
              "_id" : "sold_product_584677_19400",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T09:28:48+00:00",
              "product_name" : "Sweatshirt - grey multicolor",
              "price" : 24.99,
              "taxful_price" : 24.99,
              "base_unit_price" : 24.99
            }
          ],
          "sku" : [
            "ZO0549605496",
            "ZO0299602996"
          ],
          "taxful_total_price" : 36.98,
          "taxless_total_price" : 36.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "eddie",
          "geoip" : {
            "country_iso_code" : "EG",
            "location" : {
              "lon" : 31.3,
              "lat" : 30.1
            },
            "region_name" : "Cairo Governorate",
            "continent_name" : "Africa",
            "city_name" : "Cairo"
          }
        }
      },
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "ni9OVXIBP1shjACtvt7s",
        "_score" : 1.0,
        "_source" : {
          "category" : [
            "Women's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Mary",
          "customer_full_name" : "Mary Bailey",
          "customer_gender" : "FEMALE",
          "customer_id" : 20,
          "customer_last_name" : "Bailey",
          "customer_phone" : "",
          "day_of_week" : "Sunday",
          "day_of_week_i" : 6,
          "email" : "[email protected]",
          "manufacturer" : [
            "Champion Arts",
            "Pyramidustries"
          ],
          "order_date" : "2020-06-07T21:59:02+00:00",
          "order_id" : 584021,
          "products" : [
            {
              "base_price" : 24.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Champion Arts",
              "tax_amount" : 0,
              "product_id" : 11238,
              "category" : "Women's Clothing",
              "sku" : "ZO0489604896",
              "taxless_price" : 24.99,
              "unit_discount_amount" : 0,
              "min_price" : 11.75,
              "_id" : "sold_product_584021_11238",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T21:59:02+00:00",
              "product_name" : "Denim dress - black denim",
              "price" : 24.99,
              "taxful_price" : 24.99,
              "base_unit_price" : 24.99
            },
            {
              "base_price" : 28.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Pyramidustries",
              "tax_amount" : 0,
              "product_id" : 20149,
              "category" : "Women's Clothing",
              "sku" : "ZO0185501855",
              "taxless_price" : 28.99,
              "unit_discount_amount" : 0,
              "min_price" : 15.65,
              "_id" : "sold_product_584021_20149",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T21:59:02+00:00",
              "product_name" : "Shorts - black",
              "price" : 28.99,
              "taxful_price" : 28.99,
              "base_unit_price" : 28.99
            }
          ],
          "sku" : [
            "ZO0489604896",
            "ZO0185501855"
          ],
          "taxful_total_price" : 53.98,
          "taxless_total_price" : 53.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "mary",
          "geoip" : {
            "country_iso_code" : "AE",
            "location" : {
              "lon" : 55.3,
              "lat" : 25.3
            },
            "region_name" : "Dubai",
            "continent_name" : "Asia",
            "city_name" : "Dubai"
          }
        }
      },
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "ny9OVXIBP1shjACtvt7s",
        "_score" : 1.0,
        "_source" : {
          "category" : [
            "Women's Shoes",
            "Women's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Gwen",
          "customer_full_name" : "Gwen Butler",
          "customer_gender" : "FEMALE",
          "customer_id" : 26,
          "customer_last_name" : "Butler",
          "customer_phone" : "",
          "day_of_week" : "Sunday",
          "day_of_week_i" : 6,
          "email" : "[email protected]",
          "manufacturer" : [
            "Low Tide Media",
            "Oceanavigations"
          ],
          "order_date" : "2020-06-07T22:32:10+00:00",
          "order_id" : 584058,
          "products" : [
            {
              "base_price" : 99.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Low Tide Media",
              "tax_amount" : 0,
              "product_id" : 22794,
              "category" : "Women's Shoes",
              "sku" : "ZO0374603746",
              "taxless_price" : 99.99,
              "unit_discount_amount" : 0,
              "min_price" : 46,
              "_id" : "sold_product_584058_22794",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T22:32:10+00:00",
              "product_name" : "Boots - Midnight Blue",
              "price" : 99.99,
              "taxful_price" : 99.99,
              "base_unit_price" : 99.99
            },
            {
              "base_price" : 99.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Oceanavigations",
              "tax_amount" : 0,
              "product_id" : 23386,
              "category" : "Women's Clothing",
              "sku" : "ZO0272202722",
              "taxless_price" : 99.99,
              "unit_discount_amount" : 0,
              "min_price" : 53.99,
              "_id" : "sold_product_584058_23386",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T22:32:10+00:00",
              "product_name" : "Short coat - white/black",
              "price" : 99.99,
              "taxful_price" : 99.99,
              "base_unit_price" : 99.99
            }
          ],
          "sku" : [
            "ZO0374603746",
            "ZO0272202722"
          ],
          "taxful_total_price" : 199.98,
          "taxless_total_price" : 199.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "gwen",
          "geoip" : {
            "country_iso_code" : "US",
            "location" : {
              "lon" : -118.2,
              "lat" : 34.1
            },
            "region_name" : "California",
            "continent_name" : "North America",
            "city_name" : "Los Angeles"
          }
        }
      },

######################################################
###  一部割愛
######################################################

      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "pi9OVXIBP1shjACtvt7s",
        "_score" : 1.0,
        "_source" : {
          "category" : [
            "Women's Shoes",
            "Women's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Rabbia Al",
          "customer_full_name" : "Rabbia Al Baker",
          "customer_gender" : "FEMALE",
          "customer_id" : 5,
          "customer_last_name" : "Baker",
          "customer_phone" : "",
          "day_of_week" : "Monday",
          "day_of_week_i" : 0,
          "email" : "rabbia [email protected]",
          "manufacturer" : [
            "Oceanavigations",
            "Tigress Enterprises",
            "Champion Arts",
            "Pyramidustries"
          ],
          "order_date" : "2020-06-08T03:41:46+00:00",
          "order_id" : 727269,
          "products" : [
            {
              "base_price" : 74.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Oceanavigations",
              "tax_amount" : 0,
              "product_id" : 22880,
              "category" : "Women's Shoes",
              "sku" : "ZO0249902499",
              "taxless_price" : 74.99,
              "unit_discount_amount" : 0,
              "min_price" : 35.25,
              "_id" : "sold_product_727269_22880",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T03:41:46+00:00",
              "product_name" : "Boots - black",
              "price" : 74.99,
              "taxful_price" : 74.99,
              "base_unit_price" : 74.99
            },
            {
              "base_price" : 32.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Tigress Enterprises",
              "tax_amount" : 0,
              "product_id" : 12484,
              "category" : "Women's Clothing",
              "sku" : "ZO0068400684",
              "taxless_price" : 32.99,
              "unit_discount_amount" : 0,
              "min_price" : 17.48,
              "_id" : "sold_product_727269_12484",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T03:41:46+00:00",
              "product_name" : "Cardigan - black/white",
              "price" : 32.99,
              "taxful_price" : 32.99,
              "base_unit_price" : 32.99
            },
            {
              "base_price" : 13.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Champion Arts",
              "tax_amount" : 0,
              "product_id" : 21362,
              "category" : "Women's Clothing",
              "sku" : "ZO0494704947",
              "taxless_price" : 13.99,
              "unit_discount_amount" : 0,
              "min_price" : 6.58,
              "_id" : "sold_product_727269_21362",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T03:41:46+00:00",
              "product_name" : "Long sleeved top - blue",
              "price" : 13.99,
              "taxful_price" : 13.99,
              "base_unit_price" : 13.99
            },
            {
              "base_price" : 49.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Pyramidustries",
              "tax_amount" : 0,
              "product_id" : 13854,
              "category" : "Women's Shoes",
              "sku" : "ZO0143401434",
              "taxless_price" : 49.99,
              "unit_discount_amount" : 0,
              "min_price" : 25.49,
              "_id" : "sold_product_727269_13854",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T03:41:46+00:00",
              "product_name" : "Lace-up boots - black",
              "price" : 49.99,
              "taxful_price" : 49.99,
              "base_unit_price" : 49.99
            }
          ],
          "sku" : [
            "ZO0249902499",
            "ZO0068400684",
            "ZO0494704947",
            "ZO0143401434"
          ],
          "taxful_total_price" : 171.96,
          "taxless_total_price" : 171.96,
          "total_quantity" : 4,
          "total_unique_products" : 4,
          "type" : "order",
          "user" : "rabbia",
          "geoip" : {
            "country_iso_code" : "AE",
            "location" : {
              "lon" : 55.3,
              "lat" : 25.3
            },
            "region_name" : "Dubai",
            "continent_name" : "Asia",
            "city_name" : "Dubai"
          }
        }
      }
    ]
  }
}

始点と件数の指定を入れてみる

curl -H "Content-Type: application/json" -X GET "http://localhost:9200/kibana_sample_data_ecommerce/_search?pretty=true" -d '
{
    "query" : {
        "match_all" : {}
    },
  "from" : 1,
  "size" : 2
}'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4675,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "ni9OVXIBP1shjACtvt7s",
        "_score" : 1.0,
        "_source" : {
          "category" : [
            "Women's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Mary",
          "customer_full_name" : "Mary Bailey",
          "customer_gender" : "FEMALE",
          "customer_id" : 20,
          "customer_last_name" : "Bailey",
          "customer_phone" : "",
          "day_of_week" : "Sunday",
          "day_of_week_i" : 6,
          "email" : "[email protected]",
          "manufacturer" : [
            "Champion Arts",
            "Pyramidustries"
          ],
          "order_date" : "2020-06-07T21:59:02+00:00",
          "order_id" : 584021,
          "products" : [
            {
              "base_price" : 24.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Champion Arts",
              "tax_amount" : 0,
              "product_id" : 11238,
              "category" : "Women's Clothing",
              "sku" : "ZO0489604896",
              "taxless_price" : 24.99,
              "unit_discount_amount" : 0,
              "min_price" : 11.75,
              "_id" : "sold_product_584021_11238",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T21:59:02+00:00",
              "product_name" : "Denim dress - black denim",
              "price" : 24.99,
              "taxful_price" : 24.99,
              "base_unit_price" : 24.99
            },
            {
              "base_price" : 28.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Pyramidustries",
              "tax_amount" : 0,
              "product_id" : 20149,
              "category" : "Women's Clothing",
              "sku" : "ZO0185501855",
              "taxless_price" : 28.99,
              "unit_discount_amount" : 0,
              "min_price" : 15.65,
              "_id" : "sold_product_584021_20149",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T21:59:02+00:00",
              "product_name" : "Shorts - black",
              "price" : 28.99,
              "taxful_price" : 28.99,
              "base_unit_price" : 28.99
            }
          ],
          "sku" : [
            "ZO0489604896",
            "ZO0185501855"
          ],
          "taxful_total_price" : 53.98,
          "taxless_total_price" : 53.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "mary",
          "geoip" : {
            "country_iso_code" : "AE",
            "location" : {
              "lon" : 55.3,
              "lat" : 25.3
            },
            "region_name" : "Dubai",
            "continent_name" : "Asia",
            "city_name" : "Dubai"
          }
        }
      },
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "ny9OVXIBP1shjACtvt7s",
        "_score" : 1.0,
        "_source" : {
          "category" : [
            "Women's Shoes",
            "Women's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Gwen",
          "customer_full_name" : "Gwen Butler",
          "customer_gender" : "FEMALE",
          "customer_id" : 26,
          "customer_last_name" : "Butler",
          "customer_phone" : "",
          "day_of_week" : "Sunday",
          "day_of_week_i" : 6,
          "email" : "[email protected]",
          "manufacturer" : [
            "Low Tide Media",
            "Oceanavigations"
          ],
          "order_date" : "2020-06-07T22:32:10+00:00",
          "order_id" : 584058,
          "products" : [
            {
              "base_price" : 99.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Low Tide Media",
              "tax_amount" : 0,
              "product_id" : 22794,
              "category" : "Women's Shoes",
              "sku" : "ZO0374603746",
              "taxless_price" : 99.99,
              "unit_discount_amount" : 0,
              "min_price" : 46,
              "_id" : "sold_product_584058_22794",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T22:32:10+00:00",
              "product_name" : "Boots - Midnight Blue",
              "price" : 99.99,
              "taxful_price" : 99.99,
              "base_unit_price" : 99.99
            },
            {
              "base_price" : 99.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Oceanavigations",
              "tax_amount" : 0,
              "product_id" : 23386,
              "category" : "Women's Clothing",
              "sku" : "ZO0272202722",
              "taxless_price" : 99.99,
              "unit_discount_amount" : 0,
              "min_price" : 53.99,
              "_id" : "sold_product_584058_23386",
              "discount_amount" : 0,
              "created_on" : "2016-12-25T22:32:10+00:00",
              "product_name" : "Short coat - white/black",
              "price" : 99.99,
              "taxful_price" : 99.99,
              "base_unit_price" : 99.99
            }
          ],
          "sku" : [
            "ZO0374603746",
            "ZO0272202722"
          ],
          "taxful_total_price" : 199.98,
          "taxless_total_price" : 199.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "gwen",
          "geoip" : {
            "country_iso_code" : "US",
            "location" : {
              "lon" : -118.2,
              "lat" : 34.1
            },
            "region_name" : "California",
            "continent_name" : "North America",
            "city_name" : "Los Angeles"
          }
        }
      }
    ]
  }
}

条件指定をしてみる

curl -H "Content-Type: application/json" -X GET "http://localhost:9200/kibana_sample_data_ecommerce/_search?pretty=true" -d '
{
    "query" : {
        "match" : {
          "customer_gender" : "MALE"
        }
    },
    "size" : 3
}'
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2242,
      "relation" : "eq"
    },
    "max_score" : 0.7348517,
    "hits" : [
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "nS9OVXIBP1shjACtvt7r",
        "_score" : 0.7348517,
        "_source" : {
          "category" : [
            "Men's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Eddie",
          "customer_full_name" : "Eddie Underwood",
          "customer_gender" : "MALE",
          "customer_id" : 38,
          "customer_last_name" : "Underwood",
          "customer_phone" : "",
          "day_of_week" : "Monday",
          "day_of_week_i" : 0,
          "email" : "[email protected]",
          "manufacturer" : [
            "Elitelligence",
            "Oceanavigations"
          ],
          "order_date" : "2020-06-08T09:28:48+00:00",
          "order_id" : 584677,
          "products" : [
            {
              "base_price" : 11.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Elitelligence",
              "tax_amount" : 0,
              "product_id" : 6283,
              "category" : "Men's Clothing",
              "sku" : "ZO0549605496",
              "taxless_price" : 11.99,
              "unit_discount_amount" : 0,
              "min_price" : 6.35,
              "_id" : "sold_product_584677_6283",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T09:28:48+00:00",
              "product_name" : "Basic T-shirt - dark blue/white",
              "price" : 11.99,
              "taxful_price" : 11.99,
              "base_unit_price" : 11.99
            },
            {
              "base_price" : 24.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Oceanavigations",
              "tax_amount" : 0,
              "product_id" : 19400,
              "category" : "Men's Clothing",
              "sku" : "ZO0299602996",
              "taxless_price" : 24.99,
              "unit_discount_amount" : 0,
              "min_price" : 11.75,
              "_id" : "sold_product_584677_19400",
              "discount_amount" : 0,
              "created_on" : "2016-12-26T09:28:48+00:00",
              "product_name" : "Sweatshirt - grey multicolor",
              "price" : 24.99,
              "taxful_price" : 24.99,
              "base_unit_price" : 24.99
            }
          ],
          "sku" : [
            "ZO0549605496",
            "ZO0299602996"
          ],
          "taxful_total_price" : 36.98,
          "taxless_total_price" : 36.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "eddie",
          "geoip" : {
            "country_iso_code" : "EG",
            "location" : {
              "lon" : 31.3,
              "lat" : 30.1
            },
            "region_name" : "Cairo Governorate",
            "continent_name" : "Africa",
            "city_name" : "Cairo"
          }
        }
      },
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "oS9OVXIBP1shjACtvt7s",
        "_score" : 0.7348517,
        "_source" : {
          "category" : [
            "Men's Clothing",
            "Men's Accessories"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Eddie",
          "customer_full_name" : "Eddie Weber",
          "customer_gender" : "MALE",
          "customer_id" : 38,
          "customer_last_name" : "Weber",
          "customer_phone" : "",
          "day_of_week" : "Monday",
          "day_of_week_i" : 0,
          "email" : "[email protected]",
          "manufacturer" : [
            "Elitelligence"
          ],
          "order_date" : "2020-06-01T03:48:58+00:00",
          "order_id" : 574916,
          "products" : [
            {
              "base_price" : 59.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Elitelligence",
              "tax_amount" : 0,
              "product_id" : 11262,
              "category" : "Men's Clothing",
              "sku" : "ZO0542505425",
              "taxless_price" : 59.99,
              "unit_discount_amount" : 0,
              "min_price" : 28.2,
              "_id" : "sold_product_574916_11262",
              "discount_amount" : 0,
              "created_on" : "2016-12-19T03:48:58+00:00",
              "product_name" : "Winter jacket - black",
              "price" : 59.99,
              "taxful_price" : 59.99,
              "base_unit_price" : 59.99
            },
            {
              "base_price" : 20.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Elitelligence",
              "tax_amount" : 0,
              "product_id" : 15713,
              "category" : "Men's Accessories",
              "sku" : "ZO0601306013",
              "taxless_price" : 20.99,
              "unit_discount_amount" : 0,
              "min_price" : 10.7,
              "_id" : "sold_product_574916_15713",
              "discount_amount" : 0,
              "created_on" : "2016-12-19T03:48:58+00:00",
              "product_name" : "Watch - green",
              "price" : 20.99,
              "taxful_price" : 20.99,
              "base_unit_price" : 20.99
            }
          ],
          "sku" : [
            "ZO0542505425",
            "ZO0601306013"
          ],
          "taxful_total_price" : 80.98,
          "taxless_total_price" : 80.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "eddie",
          "geoip" : {
            "country_iso_code" : "EG",
            "location" : {
              "lon" : 31.3,
              "lat" : 30.1
            },
            "region_name" : "Cairo Governorate",
            "continent_name" : "Africa",
            "city_name" : "Cairo"
          }
        }
      },
      {
        "_index" : "kibana_sample_data_ecommerce",
        "_type" : "_doc",
        "_id" : "oy9OVXIBP1shjACtvt7s",
        "_score" : 0.7348517,
        "_source" : {
          "category" : [
            "Men's Clothing"
          ],
          "currency" : "EUR",
          "customer_first_name" : "Oliver",
          "customer_full_name" : "Oliver Rios",
          "customer_gender" : "MALE",
          "customer_id" : 7,
          "customer_last_name" : "Rios",
          "customer_phone" : "",
          "day_of_week" : "Monday",
          "day_of_week_i" : 0,
          "email" : "[email protected]",
          "manufacturer" : [
            "Low Tide Media",
            "Elitelligence"
          ],
          "order_date" : "2020-05-25T09:27:22+00:00",
          "order_id" : 565855,
          "products" : [
            {
              "base_price" : 20.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Low Tide Media",
              "tax_amount" : 0,
              "product_id" : 19919,
              "category" : "Men's Clothing",
              "sku" : "ZO0417504175",
              "taxless_price" : 20.99,
              "unit_discount_amount" : 0,
              "min_price" : 9.87,
              "_id" : "sold_product_565855_19919",
              "discount_amount" : 0,
              "created_on" : "2016-12-12T09:27:22+00:00",
              "product_name" : "Shirt - dark blue white",
              "price" : 20.99,
              "taxful_price" : 20.99,
              "base_unit_price" : 20.99
            },
            {
              "base_price" : 24.99,
              "discount_percentage" : 0,
              "quantity" : 1,
              "manufacturer" : "Elitelligence",
              "tax_amount" : 0,
              "product_id" : 24502,
              "category" : "Men's Clothing",
              "sku" : "ZO0535205352",
              "taxless_price" : 24.99,
              "unit_discount_amount" : 0,
              "min_price" : 12.49,
              "_id" : "sold_product_565855_24502",
              "discount_amount" : 0,
              "created_on" : "2016-12-12T09:27:22+00:00",
              "product_name" : "Slim fit jeans - raw blue",
              "price" : 24.99,
              "taxful_price" : 24.99,
              "base_unit_price" : 24.99
            }
          ],
          "sku" : [
            "ZO0417504175",
            "ZO0535205352"
          ],
          "taxful_total_price" : 45.98,
          "taxless_total_price" : 45.98,
          "total_quantity" : 2,
          "total_unique_products" : 2,
          "type" : "order",
          "user" : "oliver",
          "geoip" : {
            "country_iso_code" : "GB",
            "location" : {
              "lon" : -0.1,
              "lat" : 51.5
            },
            "continent_name" : "Europe"
          }
        }
      }
    ]
  }
}

最後に

検索パターンは他にもたくさんあるのでとにかく調べながら要件に合わせて試していく必要がありそうですが、試してみる分には十分なサンプルが用意されていて良いですね。
検索サンプルデータでは日本語が登場してこなかったですが、日本語を使うならanalysis-kuromojiやanalysis-icuが必要になりそうなので、そのあたりも試してみようと思います。

今回使用したymlファイルはGithubにあげていますので、もしよければご利用ください。