Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Pythonic
- ChromeDriverManager
- MariaDB
- Python.h
- rest api
- pandas
- js
- KONLPY
- ShallowCopy
- 나무자르기
- pip install mariadb
- Jpype
- tweepy
- pyLDAvis
- gensim
- ELASTIC
- jvm.py
- bulk post
- 프로그래머스
- dataframe
- 파이썬
- 완주하지못한선수
- 백준
- git bash
- bs4
- elastic search
- 토픽모델링
- centos8
- Java
- dead lock
Archives
- Today
- Total
부리부리부리
[Elastic Search] Mapping 본문
Mapping은 관계형 데이터베이스에서의 Schema와 동일하다.
Mapping없이도 ES에 데이터를 넣을 수 있지만 실무에선 상당히 위험한 일이다.
사실 RDBMS에서도 스키마없이 데이터를 관리한다는건.. 음 상상이 잘 안간다.
ES에 데이터를 넣어놓고, Kibana로 시각화를 할 때 날짜 타입을 기준으로 평균을 낸다든지, 숫자 타입의 평균을 낸다든지 할때 등등 Mapping이 필요하다.
데이터가 이미 들어가있어도 Mapping을 추가할 수 있다.
강의에서 사용하는 JSON파일을 이용하여 XPUT을 통해 매핑을 추가하려는데 자꾸 에러가 나서 찾아보니,
Elastic Search에서는 mapping 타입 중 string을 삭제하고 text로 바꾸었다고 한다.
인프런 강의를 들으시는 분들이라면
classesRating_mapping.json 파일을 열어서 string을 text로 바꾸시길!
이제 다음과 같이 시도해보자.
$ curl -XPUT 'http://localhost:9200/classes/class/_mapping?include_type_name=true' --header 'content-type: application/json' -d @classesRating_mapping.json
별 에러없이 잘 실행되었기 때문에 바로 결과를 확인해보자.
$ curl -XGET 'http://localhost:9200/classes?pretty' // 입력
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1164 100 1164 0 0 447k 0 --:--:-- --:--:-- --:--:-- 568k{
"classes" : {
"aliases" : { },
"mappings" : {
"properties" : {
"major" : {
"type" : "text"
},
"professor" : {
"type" : "text"
},
"rating" : {
"type" : "integer"
},
"school_location" : {
"type" : "geo_point"
},
"semester" : {
"type" : "text"
},
"student_count" : {
"type" : "integer"
},
"submit_date" : {
"type" : "date",
"format" : "yyyy-MM-dd"
},
"title" : {
"type" : "text"
},
"unit" : {
"type" : "integer"
}
}
},
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "1",
"provided_name" : "classes",
"creation_date" : "1670321330267",
"number_of_replicas" : "1",
"uuid" : "jdgDF6fbSWawXYjp-hrmUQ",
"version" : {
"created" : "7100299"
}
}
}
}
}
분명 Elastic Search는 DB 역할이라고 생각했는데 지금까지 공부해오며 왜 스키마 정의를 해주지않는지에 대한 의문을 가지지 않았다. 갈 길이 멀다.
'데이터 처리 > ELK' 카테고리의 다른 글
[Elastic Search] Bulk Post (0) | 2022.12.06 |
---|---|
[Elastic Search] UPDATE (0) | 2022.12.06 |
[Elastic Search] GET, PUT, POST, DELETE (0) | 2022.12.01 |
[Elastic Search] 윈도우로 Elastic Search 설치 (0) | 2022.12.01 |