아무거나

[kibana] 키바나 비주얼라이즈(Kibana Visualize) - 타일맵, 지도에 표시 본문

Data Store/Elastic Stack

[kibana] 키바나 비주얼라이즈(Kibana Visualize) - 타일맵, 지도에 표시

전봉근 2019. 5. 17. 12:03
반응형

[키바나 비주얼라이즈(Kibana Visualize) - 타일맵, 지도에 표시]

 

1. curl -XPUT 'http://localhost:9200/classes'  // 인덱스생성

 

2. curl -XPUT 'http://localhost:9200/classes/class/_mapping' -d @classesRating_mapping.json

# [classesRating_mapping.json]
{
  "class" : {
    "properties" : {
      "title" : {
        "type" : "string"
      },
      "professor" : {
        "type" : "string"
      },
      "major" : {
        "type" : "string"
      },
      "semester" : {
        "type" : "string"
      },
      "student_count" : {
        "type" : "integer"
      },
      "unit" : {
        "type" : "integer"
      },
      "rating" : {
        "type" : "integer"
      },
      "submit_date" : {
        "type" : "date",
        "format" : "yyyy-MM-dd"
      },
      "school_location" : {
      	"type" : "geo_point"
      }
    }
  }
}

 

3. curl -XGET http://localhost:9200/classes?pretty  // 매핑이 적용된걸 확인한다.

 

4. curl -XPOST http://localhost:9200/_bulk?pretty --data-binary @classes.json // 도큐먼트 생성

#[classes.json]

{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "1" } }
{"title" : "Machine Learning","Professor" : "Minsuk Heo","major" : "Computer Science","semester" : ["spring", "fall"],"student_count" : 100,"unit" : 3,"rating" : 5, "submit_date" : "2016-01-02", "school_location" : {"lat" : 36.00, "lon" : -120.00}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "2" } }
{"title" : "Network","Professor" : "Minsuk Heo","major" : "Computer Science","semester" : ["fall"],"student_count" : 50,"unit" : 3,"rating" : 4, "submit_date" : "2016-02-02", "school_location" : {"lat" : 36.00, "lon" : -120.00}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "3" } }
{"title" : "Operating System","Professor" : "Minsuk Heo","major" : "Computer Science","semester" : ["spring"],"student_count" : 50,"unit" : 3,"rating" : 4, "submit_date" : "2016-03-02", "school_location" : {"lat" : 36.00, "lon" : -120.00}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "5" } }
{"title" : "Machine Learning","Professor" : "Tim Cook","major" : "Computer Science","semester" : ["spring"],"student_count" : 40,"unit" : 3,"rating" : 2, "submit_date" : "2016-04-02", "school_location" : {"lat" : 39.00, "lon" : -112.00}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "6" } }
{"title" : "Network","Professor" : "Tim Cook","major" : "Computer Science","semester" : ["summer"],"student_count" : 30,"unit" : 3,"rating" : 2, "submit_date" : "2016-02-02", "school_location" : {"lat" : 36.00, "lon" : -120.00}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "7" } }
{"title" : "Operating System","Professor" : "Jeniffer Anderson","major" : "Computer Science","semester" : ["winter"],"student_count" : 30,"unit" : 3,"rating" : 1, "submit_date" : "2016-11-02", "school_location" : {"lat" : 39.97, "lon" : -89.78}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "8" } }
{"title" : "Algorithm","Professor" : "Tim Cook","major" : "Computer Science","semester" : ["fall"],"student_count" : 80,"unit" : 3,"rating" : 2, "submit_date" : "2016-10-22", "school_location" : {"lat" : 39.97, "lon" : -89.78}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "9" } }
{"title" : "Data Structure","Professor" : "Tim Cook","major" : "Computer Science","semester" : ["winter"],"student_count" : 50,"unit" : 3,"rating" : 2, "submit_date" : "2016-07-22", "school_location" : {"lat" : 39.97, "lon" : -89.78}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "10" } }
{"title" : "Computer Graphic","Professor" : "Jeniffer Anderson","major" : "Computer Science","semester" : ["spring"],"student_count" : 60,"unit" : 2,"rating" : 3, "submit_date" : "2016-11-12", "school_location" : {"lat" : 39.97, "lon" : -89.78}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "11" } }
{"title" : "Music Fundamental","Professor" : "Jay Z","major" : "Music","semester" : ["fall"],"student_count" : 100,"unit" : 3,"rating" : 5, "submit_date" : "2016-05-22", "school_location" : {"lat" : 42.51, "lon" : -74.83}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "12" } }
{"title" : "Vocal Techniques","Professor" : "Beyonce","major" : "Music","semester" : ["fall"],"student_count" : 30,"unit" : 3,"rating" : 5, "submit_date" : "2016-11-22", "school_location" : {"lat" : 42.51, "lon" : -74.83}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "13" } }
{"title" : "Guitar Techiniques","Professor" : "Eric Clapton","major" : "Music","semester" : ["spring", "fall"],"student_count" : 20,"unit" : 2,"rating" : 4, "submit_date" : "2016-03-12", "school_location" : {"lat" : 42.51, "lon" : -74.83}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "14" } }
{"title" : "Finance","Professor" : "Bill Gates","major" : "Accounting","semester" : ["winter"],"student_count" : 50,"unit" : 3,"rating" : 2, "submit_date" : "2016-01-12", "school_location" : {"lat" : 42.51, "lon" : -74.83}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "15" } }
{"title" : "Marketing","Professor" : "Bill Gates","major" : "Accounting","semester" : ["spring"],"student_count" : 60,"unit" : 2,"rating" : 3, "submit_date" : "2016-01-22", "school_location" : {"lat" : 42.51, "lon" : -74.83}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "16" } }
{"title" : "Accounting Information Systems","Professor" : "Tom Cruise","major" : "Accounting","semester" : ["fall"],"student_count" : 100,"unit" : 2,"rating" : 1, "submit_date" : "2016-11-12", "school_location" : {"lat" : 42.51, "lon" : -74.83}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "17" } }
{"title" : "Individual Taxation","Professor" : "Tom Cruise","major" : "Accounting","semester" : ["fall"],"student_count" : 30,"unit" : 1,"rating" : 2, "submit_date" : "2016-08-02", "school_location" : {"lat" : 42.32, "lon" : -94.74}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "18" } }
{"title" : "Auditing","Professor" : "Victoria Park","major" : "Accounting","semester" : ["spring", "fall"],"student_count" : 20,"unit" : 2,"rating" : 3, "submit_date" : "2016-09-13", "school_location" : {"lat" : 42.32, "lon" : -94.74}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "19" } }
{"title" : "Cell Biology","Professor" : "Anjella Kim","major" : "Medical","semester" : ["fall"],"student_count" : 40,"unit" : 5,"rating" : 5, "submit_date" : "2016-02-22", "school_location" : {"lat" : 42.32, "lon" : -94.74}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "20" } }
{"title" : "Physiology","Professor" : "Jack Berk","major" : "Medical","semester" : ["summer"],"student_count" : 30,"unit" : 5,"rating" : 4, "submit_date" : "2016-11-12", "school_location" : {"lat" : 32.69, "lon" : -99.44}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "21" } }
{"title" : "Neuroscience","Professor" : "Jihee Yang","major" : "Medical","semester" : ["spring", "fall"],"student_count" : 20,"unit" : 5,"rating" : 4, "submit_date" : "2016-06-03", "school_location" : {"lat" : 32.69, "lon" : -99.44}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "22" } }
{"title" : "Immunology","Professor" : "Meredith Lee","major" : "Medical","semester" : ["winter"],"student_count" : 30,"unit" : 3,"rating" : 2, "submit_date" : "2016-06-21", "school_location" : {"lat" : 32.69, "lon" : -99.44}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "23" } }
{"title" : "Genetics","Professor" : "David Pollack","major" : "Medical","semester" : ["spring"],"student_count" : 20,"unit" : 3,"rating" : 3, "submit_date" : "2016-06-30", "school_location" : {"lat" : 28.22, "lon" : -81.87}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "24" } }
{"title" : "Biochemistry","Professor" : "John Miller","major" : "Medical","semester" : ["fall"],"student_count" : 30,"unit" : 3,"rating" : 4, "submit_date" : "2016-01-11", "school_location" : {"lat" : 28.22, "lon" : -81.87}}
{ "index" : { "_index" : "classes", "_type" : "class", "_id" : "25" } }
{"title" : "Anatomy","Professor" : "Tom Johnson","major" : "Medical","semester" : ["fall"],"student_count" : 30,"unit" : 5,"rating" : 3, "submit_date" : "2016-11-12", "school_location" : {"lat" : 28.22, "lon" : -81.87}}

 

5. curl -XGET http://localhost:9200/classes/class/1?pretty  // 도큐먼트가 제대로 들어갔는지 확인

 

6. kibana에 접속하여 index를 classes로 변경하여 주면 매핑때문에 자동으로 time-field가 submit_date로 바뀐다. 그 다음 create를 클릭

 

7. 좌측메뉴에 Visualize 탭 선택 후 Coordinate Map(Tile map) 선택 후 classes 클릭 후 우측 상단에 날짜를 데이터있는 날짜로 표시하면 지도가 표시된다.

 

8. buckets > Select buckets type > Geo Coordinates 선택하고 Field를 school_location를 선택한다.

 

9. 조건 선택 후 ▶로 조회하면 결과가 지도에 표시된다.

   - 색깔이 더 진하면 진할수록 데이터가 많은것이다. 

반응형
Comments