이런데이터가 있다고하자
[js@localhost elasticsearch]$ curl -XGET localhost:9200/basketball/?pretty
{
"basketball" : {
"aliases" : { },
"mappings" : {
"record" : {
"properties" : {
"assists" : {
"type" : "long"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"points" : {
"type" : "long"
},
"rebounds" : {
"type" : "long"
},
"submit_date" : {
"type" : "date"
},
"team" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "1519972187852",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "cxRCcCVDTTCHwW75DOElXg",
"version" : {
"created" : "6020299"
},
"provided_name" : "basketball"
}
}
}
}
실제데이터는
[js@localhost elasticsearch]$ curl -XGET localhost:9200/basketball/record/1/?pretty
{
"_index" : "basketball",
"_type" : "record",
"_id" : "1",
"_version" : 3,
"found" : true,
"_source" : {
"team" : "Chicago Bulls",
"name" : "Michael Jordan",
"points" : 30,
"rebounds" : 3,
"assists" : 4,
"submit_date" : "1996-10-11"
}
}
[js@localhost elasticsearch]$ curl -XGET localhost:9200/basketball/record/2/?pretty
{
"_index" : "basketball",
"_type" : "record",
"_id" : "2",
"_version" : 3,
"found" : true,
"_source" : {
"team" : "Chicago Bulls",
"name" : "Michael Jordan",
"points" : 20,
"rebounds" : 5,
"assists" : 8,
"submit_date" : "1996-10-11"
}
}
[js@localhost elasticsearch]$
Record로 서칭을 하게되면
[js@localhost elasticsearch]$ curl -XGET localhost:9200/basketball/record/_search?pretty
{
"took" : 372,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "basketball",
"_type" : "record",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"team" : "Chicago Bulls",
"name" : "Michael Jordan",
"points" : 20,
"rebounds" : 5,
"assists" : 8,
"submit_date" : "1996-10-11"
}
},
{
"_index" : "basketball",
"_type" : "record",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"team" : "Chicago Bulls",
"name" : "Michael Jordan",
"points" : 30,
"rebounds" : 3,
"assists" : 4,
"submit_date" : "1996-10-11"
}
}
]
}
}
이렇게 인덱스를 몰라도 각각 항목에 대해서 한꺼번 조회가능함
Uri에 파라미터를 넣어서 확인도 가능함
여기서 q는 쿼리
[js@localhost elasticsearch]$ curl -XGET 'localhost:9200/basketball/record/_search?pretty&q=points:30'
{
"took" : 72,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "basketball",
"_type" : "record",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"team" : "Chicago Bulls",
"name" : "Michael Jordan",
"points" : 30,
"rebounds" : 3,
"assists" : 4,
"submit_date" : "1996-10-11"
}
}
]
}
}
-d를 이용하여 리퀘스트 바디도 가능함
'오락기 > ELK' 카테고리의 다른 글
kibana managment (0) | 2018.05.11 |
---|---|
elasticsearch aggregation (0) | 2018.05.11 |
elasticsearch mapping (0) | 2018.05.11 |
elasticsearch bulk (0) | 2018.05.11 |
elasticsearch update (0) | 2018.05.11 |