Skip to content

Instantly share code, notes, and snippets.

@kosho
Created July 20, 2018 15:08
Show Gist options
  • Save kosho/3df7fdeb7aa8cdbde0ed6f91d41d8138 to your computer and use it in GitHub Desktop.
Save kosho/3df7fdeb7aa8cdbde0ed6f91d41d8138 to your computer and use it in GitHub Desktop.
# Japan Population 2017
DELETE japan-population-2017
PUT japan-population-2017
{
"settings": {
"number_of_replicas": 0
, "number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"region_code": {
"type": "keyword"
},
"region": {
"type": "keyword"
},
"population": {
"type": "long"
},
"area": {
"type": "long"
}
}
}
}
}
POST japan-population-2017/doc/_bulk
{"index":{}}
{"region": "愛知県", "region_code": "JP-23", "population": "7526911", "area": "5172.92"}
{"index":{}}
{"region": "愛媛県", "region_code": "JP-38", "population": "1363907", "area": "5676.23"}
{"index":{}}
{"region": "茨城県", "region_code": "JP-08", "population": "2896675", "area": "6097.19"}
{"index":{}}
{"region": "岡山県", "region_code": "JP-33", "population": "1908447", "area": "7114.32"}
{"index":{}}
{"region": "沖縄県", "region_code": "JP-47", "population": "1443802", "area": "2280.98"}
{"index":{}}
{"region": "岩手県", "region_code": "JP-03", "population": "1254807", "area": "15275.01"}
{"index":{}}
{"region": "岐阜県", "region_code": "JP-21", "population": "2010698", "area": "10621.29"}
{"index":{}}
{"region": "宮崎県", "region_code": "JP-45", "population": "1088136", "area": "7735.32"}
{"index":{}}
{"region": "宮城県", "region_code": "JP-04", "population": "2322024", "area": "7282.22"}
{"index":{}}
{"region": "京都府", "region_code": "JP-26", "population": "2599313", "area": "4612.20"}
{"index":{}}
{"region": "熊本県", "region_code": "JP-43", "population": "1765518", "area": "7409.48"}
{"index":{}}
{"region": "群馬県", "region_code": "JP-10", "population": "1958409", "area": "6362.28"}
{"index":{}}
{"region": "広島県", "region_code": "JP-34", "population": "2830069", "area": "8479.63"}
{"index":{}}
{"region": "香川県", "region_code": "JP-37", "population": "967640", "area": "1876.77"}
{"index":{}}
{"region": "高知県", "region_code": "JP-39", "population": "713465", "area": "7103.86"}
{"index":{}}
{"region": "佐賀県", "region_code": "JP-41", "population": "823620", "area": "2440.68"}
{"index":{}}
{"region": "埼玉県", "region_code": "JP-11", "population": "7307579", "area": "3797.75"}
{"index":{}}
{"region": "三重県", "region_code": "JP-24", "population": "1798886", "area": "5774.41"}
{"index":{}}
{"region": "山形県", "region_code": "JP-06", "population": "1101452", "area": "9323.15"}
{"index":{}}
{"region": "山口県", "region_code": "JP-35", "population": "1381584", "area": "6112.53"}
{"index":{}}
{"region": "山梨県", "region_code": "JP-19", "population": "823580", "area": "4465.27"}
{"index":{}}
{"region": "滋賀県", "region_code": "JP-25", "population": "1412956", "area": "4017.38"}
{"index":{}}
{"region": "鹿児島県", "region_code": "JP-46", "population": "1624801", "area": "9187.01"}
{"index":{}}
{"region": "秋田県", "region_code": "JP-05", "population": "995380", "area": "11637.52"}
{"index":{}}
{"region": "新潟県", "region_code": "JP-15", "population": "2266121", "area": "12584.15"}
{"index":{}}
{"region": "神奈川県", "region_code": "JP-14", "population": "9161139", "area": "2416.17"}
{"index":{}}
{"region": "青森県", "region_code": "JP-02", "population": "1278450", "area": "9645.64"}
{"index":{}}
{"region": "静岡県", "region_code": "JP-22", "population": "3673401", "area": "7777.42"}
{"index":{}}
{"region": "石川県", "region_code": "JP-17", "population": "1147447", "area": "4186.05"}
{"index":{}}
{"region": "千葉県", "region_code": "JP-12", "population": "6255876", "area": "5157.61"}
{"index":{}}
{"region": "大阪府", "region_code": "JP-27", "population": "8831642", "area": "1905.14"}
{"index":{}}
{"region": "大分県", "region_code": "JP-44", "population": "1151853", "area": "6340.73"}
{"index":{}}
{"region": "長崎県", "region_code": "JP-42", "population": "1353550", "area": "4130.88"}
{"index":{}}
{"region": "長野県", "region_code": "JP-20", "population": "2076017", "area": "13561.56"}
{"index":{}}
{"region": "鳥取県", "region_code": "JP-31", "population": "565233", "area": "3507.13"}
{"index":{}}
{"region": "島根県", "region_code": "JP-32", "population": "684668", "area": "6708.26"}
{"index":{}}
{"region": "東京都", "region_code": "JP-13", "population": "13742906", "area": "2193.96"}
{"index":{}}
{"region": "徳島県", "region_code": "JP-36", "population": "743356", "area": "4146.80"}
{"index":{}}
{"region": "栃木県", "region_code": "JP-09", "population": "1961963", "area": "6408.09"}
{"index":{}}
{"region": "奈良県", "region_code": "JP-29", "population": "1348257", "area": "3690.94"}
{"index":{}}
{"region": "富山県", "region_code": "JP-16", "population": "1055893", "area": "4247.61"}
{"index":{}}
{"region": "福井県", "region_code": "JP-18", "population": "778329", "area": "4190.51"}
{"index":{}}
{"region": "福岡県", "region_code": "JP-40", "population": "5110338", "area": "4986.52"}
{"index":{}}
{"region": "福島県", "region_code": "JP-07", "population": "1882666", "area": "13783.90"}
{"index":{}}
{"region": "兵庫県", "region_code": "JP-28", "population": "5502987", "area": "8400.94"}
{"index":{}}
{"region": "北海道", "region_code": "JP-01", "population": "5320523", "area": "78420.79"}
{"index":{}}
{"region": "和歌山県", "region_code": "JP-30", "population": "944320", "area": "4724.64"}
GET japan-population-2017/_search
{
"size": 0,
"aggs": {
"1": {
"terms": {
"field": "region",
"order": {
"2": "desc"
},
"size": 47
},
"aggs": {
"2": {
"sum": {
"script": {
"source": "doc['population'].value/doc['area'].value",
"lang": "painless"
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment