Elasticsearch 버전 8 | mappsing, data file
curl -XPUT 'localhost:9200/basketball/_mappings' -d @basketball_mapping.json -H 'Content-Type:application/json'
{
"properties" : {
"team" : {
"type" : "text",
"fielddata" : true
},
"name" : {
"type" : "text",
"fielddata" : true
},
"points" : {
"type" : "long"
},
"rebounds" : {
"type" : "long"
},
"assists" : {
"type" : "long"
},
"blocks" : {
"type" : "long"
},
"submit_date" : {
"type" : "date",
"format" : "yyyy-MM-dd"
}
}
}
curl -XPOST 'localhost:9200/_bulk' --data-binary @bulk_basketball.json
{ "index" : { "_index" : "basketball", "_id" : "1" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry", "points" : 30,"rebounds" : 3,"assists" : 4, "blocks" : 5, "submit_date" : "2016-10-11"}
{ "index" : { "_index" : "basketball", "_id" : "2" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 32,"rebound" : 5,"assist" : 8, "blocks" : 5, "submit_date" : "2016-10-13"}
{ "index" : { "_index" : "basketball", "_id" : "3" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 28,"rebound" : 2,"assist" : 3, "blocks" : 1, "submit_date" : "2016-10-17"}
{ "index" : { "_index" : "basketball", "_id" : "4" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 36,"rebound" : 1,"assist" : 2, "blocks" : 1, "submit_date" : "2016-11-20"}
{ "index" : { "_index" : "basketball", "_id" : "5" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 36,"rebound" : 1,"assist" : 2, "blocks" : 1, "submit_date" : "2016-11-25"}
{ "index" : { "_index" : "basketball", "_id" : "6" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 32,"rebound" : 1,"assist" : 4, "blocks" : 1, "submit_date" : "2016-11-28"}
{ "index" : { "_index" : "basketball", "_id" : "7" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert", "points" : 3,"rebounds" : 11,"assists" : 4, "blocks" : 7, "submit_date" : "2016-10-12"}
{ "index" : { "_index" : "basketball", "_id" : "8" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 4,"rebound" : 13,"assist" : 8, "blocks" : 5, "submit_date" : "2016-10-14"}
{ "index" : { "_index" : "basketball", "_id" : "9" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 8,"rebound" : 10,"assist" : 3, "blocks" : 6, "submit_date" : "2016-10-18"}
{ "index" : { "_index" : "basketball", "_id" : "10" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 12,"rebound" : 9,"assist" : 2, "blocks" : 6, "submit_date" : "2016-11-10"}
{ "index" : { "_index" : "basketball", "_id" : "11" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 12,"rebound" : 14,"assist" : 2, "blocks" : 7, "submit_date" : "2016-11-22"}
{ "index" : { "_index" : "basketball", "_id" : "12" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 8,"rebound" : 10,"assist" : 4, "blocks" : 5, "submit_date" : "2016-11-27"}
{ "index" : { "_index" : "basketball", "_id" : "13" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 8,"rebound" : 1,"assist" : 13, "blocks" : 2, "submit_date" : "2016-10-18"}
{ "index" : { "_index" : "basketball", "_id" : "14" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 13,"rebound" : 2,"assist" : 12, "blocks" : 3, "submit_date" : "2016-11-10"}
{ "index" : { "_index" : "basketball", "_id" : "15" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 15,"rebound" : 3,"assist" : 12, "blocks" : 3, "submit_date" : "2016-11-22"}
{ "index" : { "_index" : "basketball", "_id" : "16" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 22,"rebound" : 4,"assist" : 14, "blocks" : 3, "submit_date" : "2016-11-27"}
回答 1
0
안녕하세요, 인프런 AI 인턴이에요.
Elasticsearch의 버전 8을 사용하고 계신 거 같네요.
요청하신 curl 명령어는 Elasticsearch에서 인덱스 매핑 및 데이터를 생성하는 부분입니다.
첫 번째 명령어는 basketball이라는 인덱스의 매핑을 설정하고 있습니다. 각각의 필드는 type을 지정하고 있고, team과 name 필드에는 fielddata를 true로 설정하고 있습니다. fielddata는 문자열 타입을 검색 가능하게 만들기 위한 설정입니다.
두 번째 명령어는 _bulk API를 사용하여 데이터를 입력하고 있습니다. 각각의 문서는 index 필드를 이용해 인덱스, id, 그리고 입력될 데이터를 지정하고 있습니다.
하지만 보시면 데이터의 일부가 잘려있는 것 같네요. 데이터의 마지막 부분이 완전하지 않은 상태입니다. 데이터 부분을 완성하고 실행하시면 정상적으로 데이터가 입력될 겁니다.
더 궁금한 점이 있으면 언제든지 물어보세요!
우분투 16.04를 vm으로 돌리고 있는데 저장을 어떻게 하나요?
0
625
1
에러 확인 부탁드립니다
0
863
2
우분투 16.04 에 엘라스틱 서치 설치시 에러
0
777
2
illegal_argument_exception 오류
2
436
0
bul_basketball.json 벌크할때 오류나시는 분들보세요
4
343
0
logstash 스타트 불가
0
298
0
json 파일 XPOST로 데이터를 입력하는데 왜 이상하게 들어가질까요..??
0
417
0
Elasticsearch 6.0 부터는 Content-Type을 명시해야한다고 합니다!
7
442
1
다중쿼리는 어떻게하나요
0
217
0
--header 옵션
0
255
1
elasticsearch 에러 관련입니다.
20
5292
6
13과 에서 날짜 선택
1
408
1
키바나가 제대로 설치되지 않습니다.
0
342
1
깃헙 파일 logstash.conf 괄호 안 닫혀 있어서 에러가 났었어요. 필터랑 아웃풋 } 하나씩 더 추가해 주어야 할듯합니다.
0
267
0
현재 7버전 이용중인데 -XPOST 시 에러가 발생합니다.
10
743
3
or 조건 쿼리
0
239
0
index 생성은 왜 XPOST가 아니라 XPUT인가요?
1
370
0
logstash 및 filebeat 실행시 오류
0
648
0
아주 기본적인 질문이 있습니다.
0
361
0
질문입니다
0
356
1
BULK 예제 실행하는데 있어 에러가 납니다.
0
557
2
name과 team의 string이 분리되는 문제는 json 파일을 다음과 같이 변경하여 해결했습니다.
6
286
1
강사님 github 주소
3
336
0
마지막 스크립트 부분
0
206
0

