반응형

1. ES 데이터 구조

  • Document
    • 데이터 최소 단위
    • 관계형 Database 에서 Row 단위
  • Type
    • 관계형 Database에서 table 단위
    • 1Type = N개 * Documents
  • Index
    • 관계형 Database에서 DB단위
    • 1 Index = N개 * Types

**ES 7.0 버전 부터는 도큐먼트 타입 개념이 사라짐. 우리는 6.x 버전 대네요.. (업그레이드도 가능 )

2.도규먼트 삽입

PUT 방식 (document id를 선택해서 삽입할 때)
curl -XPUT http://localhost:9200/books/book/1 -d
'{
"tile": "Nesoy Elastic Guide",
"author": "Nesoy",
"date": "2019-01-15",
"pages": 250
}'


PUT 방식 (document id를 선택해서 삽입할 때)
http://localhost:9200/jayden_idx01/jayden_type01/1
{
  "name":"jayden",
  "message":"안녕하세요 Elasticsearch"
}

POST 방식 (document id를 임의로 줄때)
http://localhost:9200/jayden_idx01/jayden_type01
{
  "name":"jayden",
  "message":"test1"
}

3.도큐먼트 조회

POST 전체 조회 (인덱스 별)
http://localhost:9200/jayden_test01/_search
{
  "query": {
    "match_all": {}
  }
}



POST /인덱스/_search?pretty 조건 조회
http:/localhost:9200/jayden_idx01/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "name": "jayden" } }
      ]
    }
  }}

POST
http://localhost:9200/jayden_idx01/_search
{ 
   "query" : {
        "term" : { "name" : "jayden" }
    }
}


POST 정렬 조건 조회
http://localhost:9200/jayden_idx01/_search
{
"size":1,
"sort":[
{ "@timestamp" : { "order":"desc"} }
],
"query":{
"term":{ "조건 필드": "mill" }
}

}

4.도큐먼트 삭제

DELETE /인덱스
http://localhost:9200/jayden_idx01/

 

반응형

+ Recent posts