Skip to content

Instantly share code, notes, and snippets.

@muhammadghazali
Created December 31, 2019 10:28
Show Gist options
  • Save muhammadghazali/4b9f607687eafa6c4e3a9944ca678b16 to your computer and use it in GitHub Desktop.
Save muhammadghazali/4b9f607687eafa6c4e3a9944ca678b16 to your computer and use it in GitHub Desktop.
GET /accounts

GET /accounts/_mapping

GET /accounts/_search
{
  "sort": [
    {
      "account_number": "asc"
    }
  ]
}

GET /kibana_sample_data_logs/_search
{
  "query": {
    "match": {
      "clientip": "27.253.217.206"
    }
  }
}

GET kibana_sample_data_logs/_search
{
  "query": {
    "match": {
      "host" : "www.elastic.co"
    }
  }
}

GET kibana_sample_data_logs/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "clientip": "27.253.217.206"
          }
        },
        {
          "match": {
            "host": "artifacts.elastic.co"
          }
        }
      ]
    }
  }
}

GET /shakespeare/_search
{
  "size": 0,
  "aggs": {
    "Total plays": {
      "cardinality": {
        "field": "play_name.keyword"
      }
    }
  }
}

GET accounts/_search

GET /accounts/_search
{
  "size": 0,
  "aggs": {
    "Total unique employers": {
      "cardinality": {
        "field": "employer.keyword"
      }
    }
  }
}

GET /accounts/_search
{
  "size": 0,
  "aggs": {
    "Total unique genders": {
      "cardinality": {
        "field": "gender.keyword"
      }
    }
  }
}

GET /accounts/_search
{
  "size": 0,
  "aggs": {
    "Popular employer": {
      "terms": {
        "field": "employer.keyword"
      }
    }  
  }
}

# as
GET /accounts/_search
{
  "size": 0,
  "aggs": {
    "group_by_state": {
      "terms": {
        "field": "state.keyword"
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment